
Otherwise we get the node for our xref, If the xref is the same as the last loaded, Make sure we have our mangled layer name

Loop through the list of layers, only loading xrefs Collect a list of the layers we want to clone across We're going to store a list of our xrefed databases

XrefGraph xg = db.GetHostDwgXrefGraph( false ) names of the xrefed drawings more easily Get the xref graph, which allows us to get at the of external drawings we need to load (many layers Sorting the list will allow us to minimise the number Add it to our list and flag the entity for updating If (ltr.IsDependent & !(ent is BlockReference )) Check the dependent status of the entity's layer for entities that are on dependent layers (i.e. Loop through the contents of the active space, and look
#AUTOCAD XREFS HOW TO USE UPDATE#
And store a list of the entities to come back and update We will collect the layers used by the various entities Static public void XrefOffsetCopyLayers()ĭoc.TransactionManager.StartTransaction() (_placeOnCurrentLayer ? option1 : option2) "\nEnter layer option for offset objects" Static bool _placeOnCurrentLayer = true Īpplication.

Maintain a list of temporary objects that require removal Public class XrefOffsetApplication : IExtensionApplication Using Database.wblockCloneObjects() is the cleanest approach, but there is work involved to load the xrefed DWGs into their own Database objects before using this. The copying of symbol table records from xrefs is a little involved, but I’ve don what I can to comment the approach below. The command gets called using SendStringToExecute() so that it gets executed up after control has returned to the AutoCAD application.
#AUTOCAD XREFS HOW TO USE CODE#
I decided to put the code to copy across the layers in a separate command called XOFFSETCPLAYS, which has the advantage of being callable separately from our OFFSET routine (and is generally a bit safer – performing significant operations on AutoCAD databases from event handlers can lead to problems, depending on what exactly you’re doing).
#AUTOCAD XREFS HOW TO USE PLUS#
This post evolves the approach and provides a choice to the user (via the XOFFSETLAYER command): to either create the geometry on the current layer (the default behaviour) or to clone across the layers, plus their various linetypes etc., needed for the geometry to survive independently of their originating xref. The previous example created geometry on a temporary layer that exists only as long as the source xref is attached: detaching the xref generally caused dangling layer references. I haven’t flagged the specific changes, but the old code (which is almost identical to that in the last post) starts with the Initialize() function. This post extends the last one which looked at a basic implementation to allow AutoCAD’s standard OFFSET command to work on the contents of external references.
