Author Topic: Find Grip Coordinates after insertion block  (Read 1151 times)

0 Members and 1 Guest are viewing this topic.

cmwade77

  • Swamp Rat
  • Posts: 1443
Find Grip Coordinates after insertion block
« on: August 17, 2023, 03:09:06 PM »
I have numerous dynamic blocks that I am working with, attached is one example block. I would like to get the coordinates of the grip for the parameter "Duct_1" in this case. I am honestly not sure where to even begin on this one.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8702
  • AKA Daniel
Re: Find Grip Coordinates after insertion block
« Reply #1 on: August 17, 2023, 10:02:14 PM »
It’s possible to get all the grips points in C++, I don’t know how to differentiate between them though 

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8702
  • AKA Daniel
Re: Find Grip Coordinates after insertion block
« Reply #2 on: August 17, 2023, 10:04:03 PM »
edit AcGeVector3d::kXAxis, should be Z
Code - C++: [Select]
  1.     static void CrxTest_doit1900()
  2.     {
  3.         ads_point pnt;
  4.         ads_name ename = { 0L };
  5.         if (acedEntSel(_T("\nPick it: "), ename, pnt) != RTNORM)
  6.             return;
  7.  
  8.         AcDbObjectId eid;
  9.         if (auto es = acdbGetObjectId(eid, ename); es != eOk)
  10.             return;
  11.  
  12.         AcDbEntityPointer pEnt(eid);
  13.         if (pEnt.openStatus() != eOk)
  14.             return;
  15.  
  16.         AcDbGripDataPtrArray grips;
  17.         if (auto es = pEnt->getGripPoints(grips, 1, 1, AcGeVector3d::kZAxis, 0); es != eOk)
  18.             return;
  19.  
  20.         for (const auto grip : grips)
  21.             acutPrintf(_T("\n(%f,%f,%f)"),
  22.                 grip->gripPoint().x, grip->gripPoint().y, grip->gripPoint().z);
  23.  
  24.         AcDbDynBlockReference dyn(eid);
  25.         if (!dyn.isDynamicBlock())
  26.             return;
  27.  
  28.         AcDbDynBlockReferencePropertyArray props;
  29.         dyn.getBlockProperties(props);
  30.         for (const auto& prop : props)
  31.             acutPrintf(_T("\n%ls"), prop.propertyName());
  32.     }
  33.  

Quote
Command: DOIT1900
Pick it:
(102.033146,180.850379,0.000000)
(-76.200000,152.400000,0.000000)
(-0.000000,0.000000,0.000000)
(-0.000000,152.400000,0.000000)
(-0.000000,177.800000,0.000000)
INSULATION_EXTERNAL
INSULATION_INTERNAL
INSULATION
CONNECTING_DUCT_HAS_INSULATION
INSULATION_EXTERNAL_BLOCK_TABLE
SIZE_1
Origin
ANGLE
Origin
DUCT_1
Origin
LENGTH_TOTAL
« Last Edit: August 17, 2023, 10:11:14 PM by It's Alive! »

kozmos

  • Newt
  • Posts: 114
Re: Find Grip Coordinates after insertion block
« Reply #3 on: August 18, 2023, 02:53:09 AM »
Try to add an attribute at the position you want to obtain, then u can retrieve the cooridnate of the attribute after the block is instered.

I have numerous dynamic blocks that I am working with, attached is one example block. I would like to get the coordinates of the grip for the parameter "Duct_1" in this case. I am honestly not sure where to even begin on this one.
KozMos Inc.