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_t
I've tried ed.GetNestedEntity and the AllowSubSelections property of PromptSelectionOptions and had little joy.
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.
Autodesk Developer Network
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!
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.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.