![]() transaction (there should be at most one) We'll collect any xref definitions that need reloading after our Name = Path.GetFileNameWithoutExtension(path) This Database db, string path, Point3d pos, / Whether the attach operation succeeded. / Path to the drawing file to attach as an Xref. / Attaches the specified Xref to the current space in the current drawing. ītr.PathName = root.RelativePathTo(btr.PathName) / Whether the path was changed - only fails for non-xrefs. / Path from which to create the relative path. / Changes the path of an xref's block definition to have a relative path. Return relPath.Replace( '/', Path.DirectorySeparatorChar) ![]() Var relPath = Uri.UnescapeDataString(relUri.ToString()) Var relUri = fromUri.MakeRelativeUri(toUri) Convert to URIs for the sake of the relative path determination Public static string RelativePathTo( this string from, string to) / The relative path between this one and the destination. / The path to which to return a relative path. / Generates a relative path from one string to another. Protected virtual void Dispose( bool disposing) as a document lock from a using() statement. Simple helper to make sure an object is "open for write", downgrading Here’s the updated code with the XAO and XOO commands. I could also have required the object to be open for write in the first place, but I felt like seeing if the approach worked. ![]() I also threw in a simple helper class that makes sure an object is upgraded to being open for write for the duration of its existence. I factored out the logic into a single helper method which I now call from two commands: XAO for attachments and XOO for overlays.įor relative paths, I ended up making a couple of extension methods based on this DevBlog post and this one on Stack Overflow. ![]() So I went ahead and made use of that for overlays. Henrik Ericson found the code didn’t work for him, but did spot the db.OverlayXref() method which did. Looking around, I found some code on the AutoCAD DevBlog that changes an attachment to an overlay, after the fact. After showing how to automatically attach xrefs at the origin inside AutoCAD, and then redoing the approach to take care of different unit systems, I then had the request from a couple of places to look at making the xrefs overlays and adjusting their paths to be relative rather than absolute.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |