Jump to content

Reload and Bind Xref's Question


bkkar_55

Recommended Posts

what I'm trying to do is, Check if there any (not found, or not resolved Xref's Proceed to Bind) If their Xrefs need to reload (Reload them) and then Bind all resolved Xrefs.

ObjectIdCollection btrCol = new ObjectIdCollection();
                    XrefGraph xrgraph = doc.Database.GetHostDwgXrefGraph(false);
                    db.ResolveXrefs(true, false);
                    for (int i = 1; i < (xrgraph.NumNodes); i++)
                    {
                        XrefGraphNode xrNode = xrgraph.GetXrefNode(i);                        
                        switch (xrNode.XrefStatus)
                        {
                            case XrefStatus.Resolved:
                                btrCol.Add(xrNode.BlockTableRecordId);
                                break;
                            case XrefStatus.Unloaded:
                                btrCol.Add(xrNode.BlockTableRecordId);
                                break;
                            case XrefStatus.FileNotFound:
                                break;
                            case XrefStatus.NotAnXref:
                                break;
                            case XrefStatus.Unreferenced:
                                break;
                        }
                    }
                    try
                    {
                        if (btrCol.Count > 0)
                        {
                            db.ReloadXrefs(btrCol);
                            db.BindXrefs(btrCol, true);
                        }
                    }

In debug mode, the code going well and I check the ObjectIdCollection,

 and it contains the target Xrefs and voids the (unresolved) Xref's as I need. But not Bind or Reload.

the conclusion is:

I need the code to Reload all Xref's need to reload. then Bind all. regardless any Xref's (Not Found, Not an Xref, etc...)

as the attached lisp.

(defun c:bindloaded(/ cObj cName)
  (setq cObj(tblnext "BLOCK" T))
  (while cObj
    (setq cName(cdr(assoc 2 cObj)))
    (if
      (and
	 (=(logand(cdr(assoc 70 cObj))32)32)
	 (=(logand(cdr(assoc 70 cObj))4)4)
	 ); end and
      (progn
       (vl-cmdf "bindtype" "1")
       (vl-cmdf "_.xref" "_unload" cName)
       (vl-cmdf "_.xref" "_reload" cName)
       (vl-cmdf "_.xref" "_bind" cName)
       ); end progn
      ); wnd if
  (setq cObj(tblnext "BLOCK"))
  ); end while
   (princ)
  ); end of c:bindloaded

thanks in advance.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...