.NET

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

Selecting nested entities and inheriting from BlockReference

294 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:

 

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

 

ADN Support Specialist
adam.nagy
Posts: 521
Registered: ‎03-26-2007
Message 2 of 4 (272 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
MrRamsden
Posts: 26
Registered: ‎08-29-2008
Message 3 of 4 (263 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!

 

MrRamsden

Active Contributor
MrRamsden
Posts: 26
Registered: ‎08-29-2008
Message 4 of 4 (254 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community