Jump to content

Copy Block from another drawing without running another instance of AutoCAD. [.NET]


Recommended Posts

Posted

I'm trying to create a custom plugin for AutoCAD C3D that will help me in some of my daily routines. I'm ok in C#, so I have chosen .NET API. 

 

My idea was to have template dwg with all my styles, blocks, linetypes, layers and others, and when I need some of them  to simply copy them into my active document. I have created a function to copy block by name from my template dwg and it works, but I don't like that it opens this template drawing (I know I can close it programmatically). I used Application.DocumentManager.Open() and Database..ReadDwgFile(), and in both cases it opens dwg. Is it possible to get objects from another drawing database silently, and then copy them to active document?

Posted

Have a look at Lee-mac.com,  Steal.lsp can be program driven so can do just that steal a block, and much more. Just load in your code then use the program option.

 

It is like 2 lines of code. 

 

 

Posted

Yes, I know. I've been looking at it before posting here, it's my plan B. However, I wanted to do achieve this by using .NET

Posted

Database.ReadDwgFile() is correct, you should to construct a new database buildDefaultDrawing = false, noDocument = true before reading the file

Then you can use wblock or wblock clone into to current document’s database...  as the link SLW210 shows

Posted

SLW210, Danielm103

 

Thank you both for your answers, that's it. I have looked at this example and somehow overlooked these two parameters.

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...