Kubotek Forum

KeyCreator CAD & CKD Viewer Technical discussion of CAD/CAM and integrated partner products
Customer Forum > KeyCreator CAD & CKD Viewer > Verify Mass Properties View modes: 
User avatar
Advanced member
Advanced member
Soli - 3/12/2021 1:54:00 PM
   
Verify Mass Properties
I need to attach the weight of a solid entity as a parameter of Entity Properties.
I look for a KXL function to calculate the mass properties.

Can you provide, please, some details of the function  "VerifyMassProperties".

Thanks
Solomon Steinberg,
Israel

DELL OPTIPLEX 7050
NVIDIA QUADRO P2000
KEYCREATOR 13.5
KEYCREATOR 2021 SP0



User avatar
Advanced member
Advanced member
Ram - 3/12/2021 5:00:13 PM
   
RE:Verify Mass Properties
Hi Soli,
Looks like this function was not documented. We will fix it for an upcoming version. 
The argument list is as follows:
vname aEntities,
opt vname dDensity,
opt vname dMassPerUnitArea,
opt vname adUserDefOrigin,
opt vname adAngularVelocity,
opt int bPrecise,
opt vname dVolumes,
opt vname dMasses,
opt vname dSurfAreas,
opt vname dSurfaceMasses,
opt vname adCentersOfMass,
opt vname adPrinicpalMoments,
opt vname adPrincipalAxes,
opt vname adCMMomentsOfInertia,
opt vname adCMProductsOfInertia,
opt vname adCMRadiiOfGyration,
opt vname adCMAngularMomentum,
opt vname adCMKineticEnergy,
opt vname adUserMomentsOfInertia,
opt vname adUserProductsOfInertia,
opt vname adUserRadiiOfGyration,
opt vname adUserAngularMomentum,
opt vname dUserKineticEnergy,
opt int bModelTotalCMAndPrincAxes

Here is some sample code:
Clear aBodies
HEntity aBodies[1] = { 6092 }

Double adVolumes[1]
Double adMasses[1]
Double adSurfAreas[1]
Double adCentersOfMass[3] 
 
VerifyMassProperties aBodies, , , , , 1, adVolumes, adMasses, adSurfAreas, , adCentersOfMass

Thanks,
Ram

 

Ram Eswaran
CTO
Kubotek3D

User avatar
Advanced member
Advanced member
Soli - 3/13/2021 4:42:56 AM
   
RE:Verify Mass Properties
Ram, Hello

Thank you for your help.
This function can be very valuable for me.
But something went wrong with it.
The "adCentersOfMass" parameters only, are returned.
Others give an error.

I tried this code:
------------------------------------------------
clear hEnt
HENTITY hEnt
 
:start
int nSelFlag = 0
Int  nSelParent = 1
Int  bSelRefEnts = 0
Int  bAccept = 1
bActiveInstFlag = 1
GetEnt "Select entity", hEnt,  , nSelFlag, nSelParent, bSelRefEnts,  , bAccept, bActiveInstFlag 
if (@key == -3)
exit
 
Double adVolumes[1]
Double adMasses[1]
Double adSurfAreas[1]
Double adCentersOfMass[3] 
 
VerifyMassProperties hEnt ,  ,  ,  ,  , 1, adVolumes, adMasses, adSurfAreas,  , adCentersOfMass
 
notestate
 
pause "%d  %d  %d " , adCentersOfMass[0] ,adCentersOfMass[1],adCentersOfMass[2] 
pause "%d " , adMasses
goto start
----------------------------------------------------

I recorded the function Verify>Mass Properties:
----------------------------------------------
// Begin Macro Record
// This Macro is intended to be a Macro Script
 
// (0xA5A5) Compute mass properties of a body
MASKENTITY 32 
MASKENTITY 52 
MASKENTITY 41 
MASKENTITY 26 
Clear aBodies
HEntity aBodies[1] = { 49566 }
 
Clear aGenSelLevels
HLevel aGenSelLevels[0]
 
clear aCoM
double aCoM[3]
VerifyMassProperties aBodies,,,,,,,,,,aCoM
NoteState
MASKENTITY 32 
MASKENTITY 52 
MASKENTITY 41 
MASKENTITY 26 
// End Macro Record
----------------------------------------------------
The same, only, center of mass parameters are returned.

Can you check, please?

Thanks

Solomon Steinberg,
Israel

DELL OPTIPLEX 7050
NVIDIA QUADRO P2000
KEYCREATOR 13.5
KEYCREATOR 2021 SP0



User avatar
Advanced member
Advanced member
Ram - 3/14/2021 9:15:29 PM
   
RE:Verify Mass Properties
Hi Soli,

The function takes in an array of bodies and thus returns an array of mass property values.

pause "%d " , adMasses
should be pause "%d " , adMasses[0]


Extract of KXL used in one of our regression tests:

HEntity aBodies[1] = { 6092 } // Array of bodies - only 1 in this case

Double adVolumes[1] // Array of volumes (for each body)
Double adMasses[1] // Array of masses (for each body)
Double adSurfAreas[1] // Array of surface areas (for each body)
Double adCentersOfMass[3] // Total center of mass

VerifyMassProperties aBodies, , , , , 1, adVolumes, adMasses, adSurfAreas, , adCentersOfMass
NoteState

// Volumes
Double adCorrectVolumes[1] = { 2078906.17456 }
AssertArrayEqual adVolumes, adCorrectVolumes, 0.1, "Volumes don't match"

// Masses
Double adCorrectMasses[1] = { 5613.0466713 }
AssertArrayEqual adMasses, adCorrectMasses, 0.001, "Mass doesn't match"


// Areas
Double adCorrectAreas[1] = { 219523.956038 }
AssertArrayEqual adSurfAreas, adCorrectAreas, 0.01, "Surface Areas don't match"

// Centers of Mass
Double adCorrectCM[3] = { -0.000139, 0.000018, 61.570152 }
AssertArrayEqual adCentersOfMass, adCorrectCM, 0.001, "CM does not match"


Ram Eswaran
CTO
Kubotek3D

User avatar
Advanced member
Advanced member
Soli - 3/15/2021 4:21:03 AM
   
RE:Verify Mass Properties
Ram, Hello

You won't believe how much you've helped me.
The manufacturing people, ask me to write down on the drawing the weight of the parts.
Anyway I used to attach to each solid entity non geaometrical data as:
Item no, name, material, quantity, termic treatment, coating.
Now, thank to your explanations, I can to automatically atach the weight, too.
This is a big time saving.

Thanks,
 
Solomon Steinberg,
Israel

DELL OPTIPLEX 7050
NVIDIA QUADRO P2000
KEYCREATOR 13.5
KEYCREATOR 2021 SP0



User avatar
Advanced member
Advanced member
Soli - 3/15/2021 4:46:01 AM
   
RE:Verify Mass Properties
This macro returns the weight as a string:
----------------------------------------
clear hEnt
HENTITY hEnt
 
:start
int nSelFlag = 0
Int  nSelParent = 1
Int  bSelRefEnts = 0
Int  bAccept = 1
bActiveInstFlag = 1
GetEnt "Select entity", hEnt,  , nSelFlag, nSelParent, bSelRefEnts,  , bAccept, bActiveInstFlag 
if (@key == -3)
exit
 
double weight[1]
 
VerifyMassProperties hEnt ,  ,   ,  ,  , 1,  , weight
notestate
 
VerifyMassProperties hEnt ,  ,  ,  ,  , 1,  , weight
notestate
 
weight[0] = weight[0]/1000
 
clear $weight
string $weight
sprint $weight , "%.2f" , weight[0]
 
pause "WEIGHT IS %s KG" , $weight
 
goto start
---------------------------------------------------------------------------

Ram,
Thank you again.
Solomon Steinberg,
Israel

DELL OPTIPLEX 7050
NVIDIA QUADRO P2000
KEYCREATOR 13.5
KEYCREATOR 2021 SP0



User avatar
Advanced member
Advanced member
Ram - 3/15/2021 7:38:50 AM
   
RE:Verify Mass Properties
You are very welcome Solomon. 



Ram Eswaran
CTO
Kubotek3D

User avatar
Advanced member
Advanced member
wkrol@kubotek3d.com - 3/15/2021 9:11:03 AM
   
RE:Verify Mass Properties
Just a side note.

Creating a Bounding Box on a solid will populate user props automatically with sizes & weights that stay with the bounded soild even when bounding box is deleted.  see attached.
-Wes
Post attachments:

User avatar
Advanced member
Advanced member
Soli - 3/15/2021 1:55:26 PM
   
RE:Verify Mass Properties
Wes, Hello

I made a small research about Bounding Box.
I found 
BoundingBox hEnt, , 0, 0, 0, 50, 0, 0, 0, 0
and I know how to extract KC_ScrapWeight.
But VerifyMassProperties is more simplier.

Thanks,
Solomon Steinberg,
Israel

DELL OPTIPLEX 7050
NVIDIA QUADRO P2000
KEYCREATOR 13.5
KEYCREATOR 2021 SP0



1
Login