ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

[ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

8 REPLIES 8
Reply
Message 1 of 9
gatti.massimo
880 Views, 8 Replies

[ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

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

8 REPLIES 8
Message 2 of 9
owenwengerd
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
Message 3 of 9

Yes I'm using Autocad 2013.

 

How could I override the snappoints of a block?

 

Thank you!

 

 

Message 4 of 9
owenwengerd
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
Message 5 of 9
gatti.massimo
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.

 

Message 6 of 9
Balaji_Ram
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

Message 7 of 9
alex_b
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

Message 8 of 9
owenwengerd
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
Message 9 of 9
alex_b
in reply to: owenwengerd

Owen,

 

Thank you.

I'll give it a try.

 

alex

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost