Kubotek Forum

KeyCreator CAD & CKD Viewer Technical discussion of CAD/CAM and integrated partner products
Subscribe to post
User avatar
ken.lemay@yarema.com - (12/6/2017 2:54:33 PM)
KXL Help
I have a kxl macro that tells me the size of a solid. I’ve used it for years. With  KC 2017 it now displays the wrong data.
If I create a solid block 1.000 x 2.000 x 3.000 and run the macro I get a size of 1.0025 x 2.0050 x 3.0075. Since I don’t know anything about kxl macros (I got this long ago on the old forum) can you help me?

Here is the code:


//Macro script to find the X,Y,Z Block stock for all geometry in model mode.
//This macro will find the extents in the top and right side view.
//The dimesions are all based from the view coordinates

 


:Start
//Define and clear all variables
 CLEAR PartX, PartY, PartZ
 CLEAR dModx, dModY, dModz
 CLEAR MinCoord, MaxCoord
 DOUBLE MinCoord[3], MaxCoord[3]  
 DOUBLE dModx, dMody, dModz
 PartX = 0
 PartY = 0
 PartZ = 0

:Top
// Model Mode extents of the top view 
 GetModelExtents 1, MinCoord, MaxCoord
 dModX = (MaxCoord[0] - MinCoord[0])
 dModY = (MaxCoord[1] - MinCoord[1])

:Right
// Model Mode extents of the right side view
 GetModelExtents 5, MinCoord, MaxCoord
 dModY = (MaxCoord[0] - MinCoord[0])
 dModZ = (MaxCoord[1] - MinCoord[1])


:Calculate
// calculate the smallest to the largest size to make a logical note
 If ((dModX < dModY)&&(dModX < dModZ))
  PartX = dModX
 If ((dModY < dModX)&&(dModY < dModZ))
  PartX = dModY
 If ((dModZ < dModX)&&(dModZ < dModY))
  PartX = dModZ
 If ((dModX > dModY)&&(dModX > dModZ))
  PartZ = dModX
 If ((dModY > dModX)&&(dModY > dModZ))
  PartZ = dModY
 If ((dModZ > dModX)&&(dModZ > dModY))
  PartZ = dModZ
 If ((dModX > PartX)&&(dModX < PartZ))
  PartY = dModX
 If ((dModY > PartX)&&(dModY < PartZ))
  PartY = dModY
 If ((dModZ > PartX)&&(dModZ < PartZ))
  PartY = dModZ

:MessageBox
 string $csText
 Sprint $csText, "Block Stock size is\n%.4f X %.4f X %.4f",PartX, PartY, PartZ
 MessageBox $csText, 0

:Done
 Maskclear
 Exit




Thanks
Ken
Login