Kevin Malone Posted June 13, 2023 Posted June 13, 2023 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? Quote
BIGAL Posted June 14, 2023 Posted June 14, 2023 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. Quote
Kevin Malone Posted June 14, 2023 Author Posted June 14, 2023 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 Quote
SLW210 Posted June 14, 2023 Posted June 14, 2023 Did you look at this from Kean Walmsley? Import blocks from an external DWG file using .NET - Through the Interface (typepad.com) Quote
Danielm103 Posted June 14, 2023 Posted June 14, 2023 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 Quote
Kevin Malone Posted June 15, 2023 Author Posted June 15, 2023 SLW210, Danielm103 Thank you both for your answers, that's it. I have looked at this example and somehow overlooked these two parameters. Quote
Recommended Posts
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.