Author Topic: SetExtensionDictionaryEntryFilter Method  (Read 1177 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: SetExtensionDictionaryEntryFilter Method
« Reply #15 on: March 27, 2024, 07:33:53 PM »
If you mean Xdata transform, sure

Some Xdata entries are modified in AcDbObject::xDataTransformBy. See this link for the codes
https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-RefGuide-AcDbObject__xDataTransformBy_AcGeMatrix3d_

So, if I create an object with these transformable codes, I can read them back later and see how the state has changed.
Why is this useful? Some objects may not store a normal, or a direction and it can be impossible to determine the width, height, or depth once the object is moved or rotated.

Armed with Xdata, you can build a matrix to transform the entity back to its original state to get itís bounding box

Iím using Python here, but it should be readable

Code - Python: [Select]
  1. import traceback
  2. from pyrx_imp import Rx
  3. from pyrx_imp import Ge
  4. from pyrx_imp import Gi
  5. from pyrx_imp import Db
  6. from pyrx_imp import Ap
  7. from pyrx_imp import Ed
  8. from pyrx_imp import Gs
  9.  
  10. def PyRxCmd_doit() -> None:
  11.     try:
  12.         Db.Core.regApp("MYXD")
  13.        
  14.         solid = Db.Solid3d()
  15.         solid.createBox(2.0,4.0,96.0)
  16.        
  17.         xd = [(Db.DxfCode.kDxfRegAppName, "MYXD"),
  18.               (Db.DxfCode.kDxfXdWorldXCoord, Ge.Point3d(0, 0, 0)),
  19.               (Db.DxfCode.kDxfXdWorldXDir, Ge.Vector3d.kXAxis),
  20.               (Db.DxfCode.kDxfXdWorldXDir, Ge.Vector3d.kYAxis),
  21.               (Db.DxfCode.kDxfXdWorldXDir, Ge.Vector3d.kZAxis)]
  22.        
  23.         solid.setXData(xd)
  24.         print("\nBefore",solid.xData("MYXD"))
  25.        
  26.         mat = Ge.Matrix3d()
  27.        
  28.         mat.setCoordSystem(
  29.             Ge.Point3d(100,100,100),
  30.             Ge.Vector3d.kZAxis,
  31.             Ge.Vector3d.kXAxis,
  32.             Ge.Vector3d.kYAxis)
  33.        
  34.         solid.transformBy(mat)
  35.         print("\nAfter",solid.xData("MYXD"))
  36.        
  37.         db = Db.curDb()
  38.         db.addToModelspace(solid)
  39.  
  40.     except Exception as err:
  41.         traceback.print_exception(err)
  42.  

Quote
Before [(1001, 'MYXD'),
(1011, <PyGe.Point3d(0.00000000000000,0.00000000000000,0.00000000000000)>),
(1013, <PyGe.Point3d(1.00000000000000,0.00000000000000,0.00000000000000)>),
(1013, <PyGe.Point3d(0.00000000000000,1.00000000000000,0.00000000000000)>),
(1013, <PyGe.Point3d(0.00000000000000,0.00000000000000,1.00000000000000)>)]

After [(1001, 'MYXD'),
(1011, <PyGe.Point3d(100.00000000000000,100.00000000000000,100.00000000000000)>),
(1013, <PyGe.Point3d(0.00000000000000,0.00000000000000,1.00000000000000)>),
(1013, <PyGe.Point3d(1.00000000000000,0.00000000000000,0.00000000000000)>),
(1013, <PyGe.Point3d(0.00000000000000,1.00000000000000,0.00000000000000)>)]


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8690
  • AKA Daniel
Re: SetExtensionDictionaryEntryFilter Method
« Reply #16 on: March 27, 2024, 08:44:19 PM »
Hereís a better sample
https://help.autodesk.com/view/ACDLT/2024/ENU/?guid=GUID-3481BF7B-73CB-4FD5-B421-C25BE92C6D56

Code - Python: [Select]
  1. def PyRxCmd_doit() -> None:
  2.     try:
  3.         Db.Core.regApp("MYXD")
  4.        
  5.         solid = Db.Solid3d()
  6.         solid.createBox(2.0,4.0,96.0)
  7.        
  8.         xd = [(Db.DxfCode.kDxfRegAppName, "MYXD"),
  9.               (Db.DxfCode.kDxfXdWorldXCoord, Ge.Point3d(0, 0, 0)),
  10.              
  11.               (Db.DxfCode.kDxfXdWorldXDir, Ge.Vector3d.kXAxis),
  12.               (Db.DxfCode.kDxfXdWorldXDir, Ge.Vector3d.kYAxis),
  13.               (Db.DxfCode.kDxfXdWorldXDir, Ge.Vector3d.kZAxis),
  14.              
  15.               (Db.DxfCode.kDxfXdWorldXDisp,Ge.Vector3d.kXAxis),
  16.               (Db.DxfCode.kDxfXdWorldXDisp,Ge.Vector3d.kYAxis),
  17.               (Db.DxfCode.kDxfXdWorldXDisp,Ge.Vector3d.kZAxis)]
  18.        
  19.         solid.setXData(xd)
  20.         print("\nBefore",solid.xData("MYXD"))
  21.        
  22.         mat = Ge.Matrix3d()
  23.         mat.setCoordSystem(
  24.             Ge.Point3d(100,100,100), #pos
  25.             Ge.Vector3d.kZAxis * 2,  #dir + scale
  26.             Ge.Vector3d.kXAxis * 2,
  27.             Ge.Vector3d.kYAxis * 2)
  28.        
  29.         solid.transformBy(mat)
  30.         print("\nAfter",solid.xData("MYXD"))
  31.        
  32.         db = Db.curDb()
  33.         db.addToModelspace(solid)
  34.  
  35.     except Exception as err:
  36.         traceback.print_exception(err)
  37.  

Quote
[(1001, 'MYXD'),
(1011, <PyGe.Point3d(0.00000000000000,0.00000000000000,0.00000000000000)>),

(1013, <PyGe.Vector3d(1.00000000000000,0.00000000000000,0.00000000000000)>),
(1013, <PyGe.Vector3d(0.00000000000000,1.00000000000000,0.00000000000000)>),
(1013, <PyGe.Vector3d(0.00000000000000,0.00000000000000,1.00000000000000)>),
 
(1012, <PyGe.Vector3d(1.00000000000000,0.00000000000000,0.00000000000000)>),
(1012, <PyGe.Vector3d(0.00000000000000,1.00000000000000,0.00000000000000)>),
(1012, <PyGe.Vector3d(0.00000000000000,0.00000000000000,1.00000000000000)>)]

After [(1001, 'MYXD'),
(1011, <PyGe.Point3d(100.00000000000000,100.00000000000000,100.00000000000000)>),

(1013, <PyGe.Vector3d(0.00000000000000,0.00000000000000,1.00000000000000)>),
(1013, <PyGe.Vector3d(1.00000000000000,0.00000000000000,0.00000000000000)>),
(1013, <PyGe.Vector3d(0.00000000000000,1.00000000000000,0.00000000000000)>),

(1012, <PyGe.Vector3d(0.00000000000000,0.00000000000000,2.00000000000000)>),
(1012, <PyGe.Vector3d(2.00000000000000,0.00000000000000,0.00000000000000)>),
(1012, <PyGe.Vector3d(0.00000000000000,2.00000000000000,0.00000000000000)>)]

I just changed the python wrappers to return the correct type, pretty sure .NET returns points instead of vectors

Augusto

  • Newt
  • Posts: 75
Re: SetExtensionDictionaryEntryFilter Method
« Reply #17 on: March 28, 2024, 02:09:27 PM »
Thanks for the answer with examples. It was very clear to me.