ObjectARX

ObjectARX

Reply
Valued Contributor
gatti.massimo
Posts: 50
Registered: ‎10-09-2013
Message 1 of 9 (336 Views)

[ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

336 Views, 8 Replies
10-09-2013 08:19 AM

Hi Everyone,

I create myCustomAcDbBlockReference class deriving the AcDbBlockReference in order to add custom snap points to blocks.

 

I successfully override the osnap protocol methods, but in my objects I loose the AcDbAttribute associated to the Block.

 

If I insert a block with an AcDbBlockReference I'm able to get all its attributes.

 

If I insert a block with my own AcDbBlockReference class I have no AcDbAttribute on it.

 

I lose them!

 

Should I Implement something in my child class? for example an iterator?

 

Thank you for your help!

Massimo

Distinguished Mentor
owenwengerd
Posts: 676
Registered: ‎08-06-2002
Message 2 of 9 (332 Views)

Re: [ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

10-09-2013 09:00 AM in reply to: gatti.massimo

AutoCAD's attributes are hard coded to work only with AcDbBlockReference and not with derived classes. Which versions of AutoCAD are you targeting? If only AutoCAD 2010 and later versions, you can use an overrule instead to add your custom snap points.

--
Owen Wengerd
ManuSoft
Valued Contributor
gatti.massimo
Posts: 50
Registered: ‎10-09-2013
Message 3 of 9 (326 Views)

Re: [ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

10-09-2013 09:36 AM in reply to: gatti.massimo

Yes I'm using Autocad 2013.

 

How could I override the snappoints of a block?

 

Thank you!

 

 

Distinguished Mentor
owenwengerd
Posts: 676
Registered: ‎08-06-2002
Message 4 of 9 (321 Views)

Re: [ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

10-09-2013 10:28 AM in reply to: gatti.massimo

You need to use the overrule API. Sorry, I don't have an example handy, but you can find plenty of information and even specific examples for adding snap points if you search.

--
Owen Wengerd
ManuSoft
Valued Contributor
gatti.massimo
Posts: 50
Registered: ‎10-09-2013
Message 5 of 9 (302 Views)

Re: [ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

10-10-2013 01:00 AM in reply to: owenwengerd

Ok, I looked at the overrules API and it seems the right way,

 

but

 

if I add an overrule on the AcDbBlockReference, the overrule will be used for ALL the blockreference added in my drawing?

 

I seen this example: http://adndevblog.typepad.com/autocad/2012/06/locking-an-entity-in-autocad-using-objectarx.html

 

Where I have to put my class definition? on the arx or on the dbx project?

 

Thank you for your help.

 

ADN Support Specialist
Balaji_Ram
Posts: 737
Registered: ‎03-21-2011
Message 6 of 9 (291 Views)

Re: [ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

10-11-2013 03:33 AM in reply to: gatti.massimo

Hi,

 

Here is a blog post on setting up a OSnap overrule for a block reference. The code is in C# but similar method also exist in C++. 

http://adndevblog.typepad.com/autocad/2013/06/overruling-osnaps-of-blockreference.html

 

Hope this helps.



Balaji
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
alex_b
Posts: 405
Registered: ‎08-15-2003
Message 7 of 9 (200 Views)

Re: [ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

01-15-2014 01:58 PM in reply to: owenwengerd

Owen,

 

>>AutoCAD's attributes are hard coded to work only with AcDbBlockReference

What about the inverse case: can one derive from AcDbAttribute in order to modify its behaviour, and use the custom entity in a regular AcDbBlockReference?

 

Thanks

 

alex

Distinguished Mentor
owenwengerd
Posts: 676
Registered: ‎08-06-2002
Message 8 of 9 (196 Views)

Re: [ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

01-15-2014 02:18 PM in reply to: alex_b

alex_b wrote:

What about the inverse case: can one derive from AcDbAttribute in order to modify its behaviour, and use the custom entity in a regular AcDbBlockReference?


I suspect it would work, but I don't know as I've never tried. Even if it works fine in most cases though, I wouldn't be surprised if there were some bugs or unexpected behaviors that result in certain circumstances.

--
Owen Wengerd
ManuSoft
Distinguished Contributor
alex_b
Posts: 405
Registered: ‎08-15-2003
Message 9 of 9 (189 Views)

Re: [ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

01-15-2014 08:25 PM in reply to: owenwengerd

Owen,

 

Thank you.

I'll give it a try.

 

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!