.NET

Reply
Distinguished Contributor
alex_b
Posts: 405
Registered: ‎08-15-2003
Message 1 of 8 (489 Views)
Accepted Solution

Modify block definition

489 Views, 7 Replies
09-24-2012 06:06 AM

Hi.

I'm trying to modify Block definitions in dwg files from an out-of-process app.

    It has to work for ACAD 2004.

I can add entities to the block definition but only when I know the entity type in advance (e.g. block.AddLine() etc.).

What I mean is I need to copy entities from a source (e.g. another drawing) and add them to the block definition, without checking the entity type.
I notice there is no generic AcadBlock.Add() or AddObject() or AddEntity().
Would it be possible to do it at all?

Thanks

alex

Not sure about if this helps,

try the quick code example,

just change file names and block name

to your suit

 

~'J'~

Distinguished Mentor
gasty1001
Posts: 581
Registered: ‎04-11-2010
Message 2 of 8 (479 Views)

Re: Modify block definition

09-24-2012 07:32 AM in reply to: alex_b

Hi,

 

Firts the bad news: 2004 does not support .NET API, you need 2005 at least, but that was almost experimental, so it's better to get a more modern version of AutoCAD. As for the block definition, you can check this: http://through-the-interface.typepad.com/through_the_interface/2010/01/creating-an-autocad-block-usi...

 

Gaston Nunez

Distinguished Contributor
alex_b
Posts: 405
Registered: ‎08-15-2003
Message 3 of 8 (468 Views)

Re: Modify block definition

09-24-2012 08:20 AM in reply to: gasty1001
Spoiler
 

Hi Gaston

I am using COM ActiveX quite successfully for 2004.

I saw Kean's article at his blog, it's not quite what I need.

I'm looking for a solution to the specific problem I mentioned.

Maybe the Autodesk people will see this and come forward.

You said 'first the bad news'.

OK. Where are the good news? :smileyhappy:

Distinguished Mentor
gasty1001
Posts: 581
Registered: ‎04-11-2010
Message 4 of 8 (465 Views)

Re: Modify block definition

09-24-2012 08:31 AM in reply to: alex_b

Hi,

 

Well, this is the .NET forum, may be you can find more help in the VB/VBA forum.

 

Gaston Nunez

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 5 of 8 (425 Views)

Re: Modify block definition

09-25-2012 08:58 AM in reply to: alex_b

Not sure about if this helps,

try the quick code example,

just change file names and block name

to your suit

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
alex_b
Posts: 405
Registered: ‎08-15-2003
Message 6 of 8 (415 Views)

Re: Modify block definition

09-25-2012 11:06 AM in reply to: Hallex

Hallex

Awesome, Thank you. This is just what I'm looking for.

I wasn't aware of AcadDocument.CopyObjects().

All I have to do now is translet your VB code to C#.

Thx again

alex

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 7 of 8 (406 Views)

Re: Modify block definition

09-25-2012 12:58 PM in reply to: alex_b

You're welcome,

Glad to help

Cheers :smileyhappy:

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Distinguished Contributor
alex_b
Posts: 405
Registered: ‎08-15-2003
Message 8 of 8 (386 Views)

Re: Modify block definition

09-26-2012 04:05 AM in reply to: Hallex

In case it will be useful to anyone, here is a method, based on Hallex's code translated to C# Interop,

which performs a INSERT =.

Cheers

alex

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!