Active Contributor
Posts: 26
Registered: ‎08-29-2008
Message 1 of 4 (346 Views)

Selecting nested entities and inheriting from BlockReference

346 Views, 3 Replies
05-01-2012 02:54 AM

Hi all


My primary goal in this exercise is to select a nested polyline within a block and have access to its grips. I'm still not even sure if it's possible, so if anyone knows either way, please let me know.


However, before I'm even getting to that stage I'm hitting some problems. I have some custom objects which all in some way or another inherit from BlockReference:



-Derived Abstract Class with common attributes

-Derived Concrete Class1

-Derived Concrete Class2

-Derived Concrete Class3


I insert instances of my derived concrete classes using jigs( Class2 for example is created using a polyline jig). However, when I select the block generated from it using a PromptSelectionResult, it returns a BlockReference, not the derived concrete class, not the derived abstract class.


When I try and cast that as the correct class type I get an error telling me I can't cast from the Base class to any of the derived classes.


So, firstly, why is it returning a BlockReference when the object I'm clicking on is an instance of a type that indirectly inherits BlockReference? And is it even possible to gain access to a nested entity's grips? I followed Kean's post here: http://through-the-interface.typepad.com/through_the_interface/2006/12/highlighting_an.html but it doesn't give me what I need.


I've tried ed.GetNestedEntity and the AllowSubSelections property of PromptSelectionOptions and had little joy.


Any ideas?






ADN Support Specialist
Posts: 614
Registered: ‎03-26-2007
Message 2 of 4 (324 Views)

Re: Selecting nested entities and inheriting from BlockReference

05-01-2012 04:15 PM in reply to: MrRamsden

Hi there,


Maybe I'm misunderstanding what you are saying, but since you did not mention ARX it sounds like you are trying to create a custom entity solely in .NET?

If so, that won't work.


First you need a custom entity created using the ARX (C++) API and then you need to create a mixed managed module that will create a .NET wrapper for the ARX custom entity.

You can find a sample project for this in the ARX SDK under \samples\entity\polysamp

This provides both a COM and .NET wrapper for the custom entity.


In .NET we introduced something called overrule - it is a bit like custom entities from the point of view of being able to customize the look and behaviour of AutoCAD entities without actually having to create custom entities in ARX.


I hope this helps.


Adam Nagy

Autodesk Developer Network

Adam Nagy
Developer Technical Services
Autodesk Developer Network
Active Contributor
Posts: 26
Registered: ‎08-29-2008
Message 3 of 4 (315 Views)

Re: Selecting nested entities and inheriting from BlockReference

05-01-2012 11:42 PM in reply to: adam.nagy

Hi Adam


Thanks for the reply. I was not aware of that limitation in .NET, looks like I'm going to have to exercise my C++ skills.


I assume that explains the "One or more objects in this drawing cannot be saved to the specified format." message I get when saving? That's a shame. I was under the impression that .NET was the way forward with AutoCAD development.


Wish me luck!



Active Contributor
Posts: 26
Registered: ‎08-29-2008
Message 4 of 4 (306 Views)

Re: Selecting nested entities and inheriting from BlockReference

05-02-2012 02:39 AM in reply to: adam.nagy

Just to clarify, what counts as a custom object?


Originally I was using the standard BlockReference class to insert a block, and then attached Xrecords and DBDictionaries to it to hold custom data per block.


It's only recently I've tried creating a class that inherits from BlockReference since I have 3 ways of creating blocks that will essentially hold the same types of data (AttributeReferences, attribute positions, type etc), and it would be useful to be able to identify them under one object type from normal blocks. Both throw the "One or more objects...." message, despite my first effort only using the existing BlockReference class.


At this moment in time I can't see how overrules will help, or even which overrule I'd apply. A wrapper looks like it's going to be over my head.


From what I've read it sounds like a BlockReference, with Xrecords and DBDictionaties to hold custom data, is the simple way to go, in terms of getting code that works. After that I guess a gripoverrule might get me access to nested object grips?


I don't think I'm trying to reinvent the wheel, it all just feels... messy.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
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!