ObjectARX

ObjectARX

Reply
Valued Contributor
50 Posts
0 Kudos
Registered: ‎10-09-2013
Post 1 of 9

[ACAD2013] Derive from AcDbBlockReference AcDbAttribute lots!

357 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
739 Posts
100 Kudos
Registered: ‎08-06-2002
Post 2 of 9

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
50 Posts
0 Kudos
Registered: ‎10-09-2013
Post 3 of 9

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
739 Posts
100 Kudos
Registered: ‎08-06-2002
Post 4 of 9

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
50 Posts
0 Kudos
Registered: ‎10-09-2013
Post 5 of 9

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
762 Posts
100 Kudos
Registered: ‎03-21-2011
Post 6 of 9

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
405 Posts
4 Kudos
Registered: ‎08-15-2003
Post 7 of 9

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
739 Posts
100 Kudos
Registered: ‎08-06-2002
Post 8 of 9

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
405 Posts
4 Kudos
Registered: ‎08-15-2003
Post 9 of 9

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 interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!