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

Selecting nested entities and inheriting from BlockReference

3 REPLIES 3
Reply
Message 1 of 4
MrRamsden
754 Views, 3 Replies

Selecting nested entities and inheriting from BlockReference

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:

 

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?

 

Cheers

 

MrRamsden

 

3 REPLIES 3
Message 2 of 4
adam.nagy
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
Autodesk Platform Services
Message 3 of 4
MrRamsden
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!

 

MrRamsden

Message 4 of 4
MrRamsden
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.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost