ObjectARX

Reply
New Member
xuegao007
Posts: 2
Registered: ‎03-18-2010
Message 1 of 12 (437 Views)

custom entity, how to extend or trim???

437 Views, 11 Replies
06-28-2012 08:38 PM

custom entity, how to extend or trim???

Distinguished Mentor
owenwengerd
Posts: 645
Registered: ‎08-06-2002
Message 2 of 12 (436 Views)

Re: custom entity, how to extend or trim???

06-28-2012 08:47 PM in reply to: xuegao007

Derive from AcDbCurve and implement AcDbCurve virtual members.

--
Owen Wengerd
ManuSoft
Distinguished Contributor
maisoui
Posts: 132
Registered: ‎12-07-2009
Message 3 of 12 (373 Views)

Re: custom entity, how to extend or trim???

11-26-2012 12:42 AM in reply to: owenwengerd

Hi,

 

I already derived my custom entity from AcDbText for annotativity protocol. So, is there another way to support TRIM, EXTEND and BREAK commands? It works with AcDbHatch.

 

Regards,

Jonathan

 

--
Jonathan
ADN Support Specialist
philippe.leefsma
Posts: 646
Registered: ‎06-02-2009
Message 4 of 12 (344 Views)

Re: custom entity, how to extend or trim???

12-04-2012 07:19 AM in reply to: maisoui

H Jonathan,

 

Not all entities can be extended or trimmed. Did you try trimming an AcDbText? This is unlikely that you will be able to do so. As mentionned by Owen, you would need to derive from AcDbCurve in order to achieve that.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
maisoui
Posts: 132
Registered: ‎12-07-2009
Message 5 of 12 (341 Views)

Re: custom entity, how to extend or trim???

12-04-2012 07:27 AM in reply to: philippe.leefsma

Hi,

 

Your teamate told me I need to derive from AcDbText to implement Annotation protocol. Apparently, this is the unique solution to have annotative custom objet, and no API change is envisaged. So, no I have annotative custom object but the downside is a lot of other features don't work:

  • Hatch
  • Trim, extend and break methods
  • Grip and snap points need to be all re-implemented instead of inheriting of AcDbCurve

I can't derive from both AcDbCurve and AcDbText. So what can I do?

 

Regards,

Jonathan

 

--
Jonathan
ADN Support Specialist
philippe.leefsma
Posts: 646
Registered: ‎06-02-2009
Message 6 of 12 (336 Views)

Re: custom entity, how to extend or trim???

12-04-2012 09:44 AM in reply to: maisoui

Yes that's correct, you cannot implement the annotative protocol by yorself, you need to derive from an existing annotative entity. Here they are:

 

Text, MText, Dimenions, Leaders, Balloons, Tolerance, Tables, Blocks, Attributes, Hatches are the standard built-in annotative entities. If you derive from these built-in annotative entities, you will automatically inherits the scale context framework and will be able to support annotative scales.

 

I'm affraid that having an annotative curve entity isn't doable because as you mentionned you cannot derive from both classes. One suggestion maybe to embedd an AcDbCurve or custom class derived from it inside your custom entity derived from an annotative class mentionned above. This way you wouldn't really need to reimplement all the grip/snap points as you could simply return the ones of the embedded curve. However this probably won't allow AutoCAD to accept your entity when running trim or extend commands as it is not the right type. You could redefine those commands and perform a type check then invoke some custom code or the native command depending if it is your custom entity or a native curve.

 

I hope it helps.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
maisoui
Posts: 132
Registered: ‎12-07-2009
Message 7 of 12 (325 Views)

Re: custom entity, how to extend or trim???

12-06-2012 01:28 AM in reply to: xuegao007

Hi,

 

Thank your for your answer. Can I ask you what is the best way to redifine Acad commands? (reactors or register a custom command with the same name or ...?). I need a independant-language solution because my customers could be french, italian or german.

 

Regards,

Jonathan

 

--
Jonathan
ADN Support Specialist
philippe.leefsma
Posts: 646
Registered: ‎06-02-2009
Message 8 of 12 (319 Views)

Re: custom entity, how to extend or trim???

12-06-2012 05:19 AM in reply to: maisoui

Using reactors won't allow you to replace a native command by your own. Only way to achieve that is to undefine the command and redefine a custom one with the same name. In addition to that there is no language indepedent approach as you need to work with the localized command names, so it's very likely that you would need to either produce language specific dlls or detect the AutoCAD language from your code and act upon.

 

Here are links that may be useful comcerning undefining/redefining commands:

 

http://adndevblog.typepad.com/autocad/2012/07/undefining-autocad-commands.html

 

http://through-the-interface.typepad.com/through_the_interface/2007/03/replacing_the_o.html



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Distinguished Contributor
maisoui
Posts: 132
Registered: ‎12-07-2009
Message 9 of 12 (315 Views)

Re: custom entity, how to extend or trim???

12-06-2012 05:48 AM in reply to: philippe.leefsma

Hi,

 

Thank you for your suggestion. I will explore this solution.

I was wondering if it could be possible to implement a reactor on commandWillStart or commandEnded and when command is TRIM/EXTEND, check if current selection set of entities contains at least one of my custom entity and act like the command for these particular entities. What do you think about this idea? (the big advantage is that it's language independant)

 

Regards,

Jonathan

 

--
Jonathan
ADN Support Specialist
philippe.leefsma
Posts: 646
Registered: ‎06-02-2009
Message 10 of 12 (308 Views)

Re: custom entity, how to extend or trim???

12-06-2012 10:33 AM in reply to: maisoui

One issue with that approach is that when user is starting the command, hence commandWillStart being fired, no entity may have been selected yet, they will be selected only once the command is running.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.