ObjectARX

Reply
Active Contributor
gatti.massimo
Posts: 34
Registered: ‎10-09-2013
Message 1 of 9 (304 Views)

[ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

304 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: 606
Registered: ‎08-06-2002
Message 2 of 9 (300 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
Active Contributor
gatti.massimo
Posts: 34
Registered: ‎10-09-2013
Message 3 of 9 (294 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: 606
Registered: ‎08-06-2002
Message 4 of 9 (289 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
Active Contributor
gatti.massimo
Posts: 34
Registered: ‎10-09-2013
Message 5 of 9 (270 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: 666
Registered: ‎03-21-2011
Message 6 of 9 (259 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: 393
Registered: ‎08-15-2003
Message 7 of 9 (168 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: 606
Registered: ‎08-06-2002
Message 8 of 9 (164 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: 393
Registered: ‎08-15-2003
Message 9 of 9 (157 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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community