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.
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.
Solved! Go to Solution.
Solved by tbrammer. Go to Solution.
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.
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.
@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.
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!
@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:
I can only imagine this scenario which could make sense:
Can't find what you're looking for? Ask the community or share your knowledge.