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

Snapping on Proxy Entities/Objects

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
bart
7156 Views, 6 Replies

Snapping on Proxy Entities/Objects

Hi All, 

 

I was wondering if it is possible to create custom entities that can be snapped on when they are turned into proxy entities. 

I have already read and implemented the following information. 

 

https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2017/ENU/OARXMAC-DevGuide/file...

 

And this works fine, I can now MOVE and ERASE my proxy entities, but I cannot find anything about allowing SNAP on my proxy entities. 

 

Any information about this, or example code in c++ , will be greatly appreciated! 

 

Thank you in advance. 

 

Tags (2)
6 REPLIES 6
Message 2 of 7
artc2
in reply to: bart

Proxies don't provide any way to support snap or grip points for the entity they represent.

You could use overrules to provide osnap and/or grips for proxies, but that would apply to all proxy entities regardless of what entity types they represent and your overrule would not have access to any of the data specific to the entity the proxy represents.
Message 3 of 7
tbrammer
in reply to: bart

I wonder whether you mixed up the terms "Proxy Entity" and "Custom Entity".

If AutoCAD can't find an Object Enabler for a Custom Entity class, it treats this unknown entity as a Proxy.

If you implement a Custom Entity class, than you write the Object Enabler yourself. And you can implement snap-methods in the entity class by overwriting the appropriate virtual methods:

 

    // AcDbOsnapOverrule
    virtual Acad::ErrorStatus   subGetOsnapPoints(
                                    AcDb::OsnapMode     osnapMode,
                                    Adesk::GsMarker     gsSelectionMark,
                                    const AcGePoint3d&  pickPoint,
                                    const AcGePoint3d&  lastPoint,
                                    const AcGeMatrix3d& viewXform,
                                    AcGePoint3dArray&   snapPoints,
                                    AcDbIntArray &   geomIds) const;
    virtual Acad::ErrorStatus   subGetOsnapPoints(
                                    AcDb::OsnapMode     osnapMode,
                                    Adesk::GsMarker     gsSelectionMark,
                                    const AcGePoint3d&  pickPoint,
                                    const AcGePoint3d&  lastPoint,
                                    const AcGeMatrix3d& viewXform,
                                    AcGePoint3dArray&   snapPoints,
                                    AcDbIntArray &   geomIds,
                                    const AcGeMatrix3d& insertionMat) const;

These will be called by AutoCAD, if your Object Enabler is loaded.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 4 of 7
bart
in reply to: tbrammer

Hi tbrammer,

 

Thanks for replying! I don't think I am mixing them up. When I load my drawing with my own custom entities in my objectarx project, it has snap points and grip points. These snap points and grip points are indeed created by overwriting the virtual methods you referenced. 

But when I load the same drawing in autocad without my objectarx project (the Object Enabler), my custom entities become proxy entities as suspected. But these proxy entities don't have any grip or snap points. So I was wondering if this is normal? And how I could create snap or grip points on my custom entities that still remain there when they become proxy entities. 

 

My custom entities are inherited from AcDbEntity.

 

 

 

Message 5 of 7
tbrammer
in reply to: bart


@Anonymous wrote:
(...)these proxy entities don't have any grip or snap points. So I was wondering if this is normal? And how I could create snap or grip points on my custom entities that still remain there when they become proxy entities.

AutoCAD doesn't "store" the snappoints together with the entity. It calls the subGetOsnapPoints() methods directly from the OE if it needs snappoints. So snapping just can't work if the OE isn't loaded.

 

It would  be nice to have an option to store snappoint types like "end", "center" directly at custom entities. So AutoCAD could snap to proxies even without OE. Snappoint types like "intersection" still definitely need an OE.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 6 of 7
bart
in reply to: tbrammer

That would indeed be nice! 🙂 But I understand that it is not directly possible right now so I am not going to put more time in it and will accept this as the solution. 

 

Thank you again for all the help!

Message 7 of 7
tbrammer
in reply to: bart

@artc2 pointed out how you could use overrules to implement snap for proxies.

He is right, that your overrule would apply to all proxy types. But you can determine the original class name of the proxy entity with AcDbProxyEntity::originalClassName() and implement snapping only for your class.

But:

  1. if no OE is loaded you won't have acces to the data of the custom entity. How would you determine snappoints than?
    This could only work, if you add snap data as XData / XRecord.
  2. This is pointless at all, because it would require a DBX/ARX to be loaded, that implements the overrule.
    So why not simply load the OE instead?

I can only imagine this scenario which could make sense:

 

  • You don't want to publish your OEs for some reason
  • You add snappoints as XData to all your custom entities
  • You create and publish a DBX that implements snapping based on your XData snappoints for proxies. This can be used for all your custom entity classes.

Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

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

Post to forums  

Forma Design Contest


Autodesk Design & Make Report