cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

TOOLKIT APPLICATION TO GENERATE POSITION AND MAX DIMENSION BY CSYS

Luca_Carraro
12-Amethyst

TOOLKIT APPLICATION TO GENERATE POSITION AND MAX DIMENSION BY CSYS

Hi,

to automate the drawin of numerous part, has

anyone made a Creo toolkit application that can generate max dimensions for a given 3D model?

3 parameters must be generated in the 3D model

MAX_LENGTH_X

MAX_WIDTH _Y

MAX_ HEIGTH_Z

and  coordinate of max points alwais  referred by coordinate system (see example measure transform) ?

Thanks for your time, Luca.

2 REPLIES 2
RPN
17-Peridot
17-Peridot
(To:Luca_Carraro)

Just a simple proc

The Input is the name of the Csys and the name of the solid.

Extract the Matrix from the Csys, and feed this for calculation the outline

  1. Get a ModelItem Obj
  2. Make sure the given csys name exists
  3. Get the Geom ID
  4. Extract the csys data
  5. Get the matrix
  6. Get the outline
  7. Get the vector (x,y,z)
  8. In a loop create/update the parameter

Only if the csys is rotated, the values will differ from the default.

 

proc Get_Outline_Ref_By_Creo {CSYS MODEL} {
# Get the matrix out of an existing CSYS
  ps_modelitem miObj
  set found [miObj byname $MODEL csys $CSYS]
  if {$found == 0} {
    ps_mess "CSYS $CSYS not found in Model $MODEL"
    return 1
  }
# Get the GeomID from CSYS modelitem
  set GeomID [miObj cget -id]
# Get the Orientation Matrix from this Csys
  ps_data csys -model [ps_model cur]  $GeomID csysObj
# Now feed a Matrix based on the Csys
  csysObj matrix matrixObj
# The is a line in 3D Space
  set exclList [list ALL_CRVS AXES CSYS PLANE POINT]
  ps_data outline -model $MODEL -matrix matrixObj -exclude $exclList lineObj
# Need only the max dims x2-x1, y2-y1 and z2-z1 this is a point with 3 values
  lineObj diff maxPoint
# maxPoint 3d_values will return the x,y and z value
  foreach  pname {MAX_LENGTH_X MAX_LENGTH_Y MAX_LENGTH_Z} val [maxPoint 3d_values] {
    ps_mess "Creo  set $pname $val"
    ps_param set -model $MODEL  $pname DOUBLE $val
  }
# No error
  return 0
}
 
Called with:
 
  Get_Outline_Ref_By_Creo cs0 [ps_model cur]
 
Here a screenshot

doc00451.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Or do it by yourself

 

proc Get_Outline_Ref_By {CSYS MODEL} {
# Get the matrix out of an existing CSYS
  ps_modelitem miObj
  set found [miObj byname $MODEL csys $CSYS]
  if {$found == 0} {
    ps_mess "CSYS $CSYS not found in Model $Model"
    return 1
  }
 
# Get the GeomID from CSYS modelitem
  set GeomID [miObj cget -id]
 
# Get the Orientation Matrix from this Csys
  ps_data csys -model [ps_model cur]  $GeomID csysObj
 
# Now feed a Matrix
# based on the Csys
  csysObj matrix matrixObj
 
# The is a line in 3D Space
  ps_solid outline -model $MODEL lineObj
 
# Multiply the with the csys Matrix
# Create a new lineObj
  lineObj transform matrixObj lineTransObj
 
# Need only the max dims
# x2-x1, y2-y1 and z2-z1
# this is a point with 3 
  lineTransObj diff maxPoint
#
# maxPoint 3d_values will return the x,y and z value
#
  foreach  pname {MAX_LENGTH_X MAX_LENGTH_Y MAX_LENGTH_Z} val [maxPoint 3d_values] {
    ps_mess "Manual set $pname $val"
    ps_param set -model $MODEL  $pname DOUBLE $val
  }
 
  return 0
}

 

 

 

or just get an outline

 

proc Get_Outline {MODEL} {
 
# The is a line in 3D Space
  ps_solid outline -model $MODEL lineObj
 
# Need only the max dims
# x2-x1, y2-y1
# this is a point with 3 
 
  lineObj diff maxPoint
 
#
# maxPoint 3d_values will return the x,y and z value
#
  foreach  pname {MAX_LENGTH_X MAX_LENGTH_Y MAX_LENGTH_Z} val [maxPoint 3d_values] {
    ps_param set -model $MODEL  $pname DOUBLE $val
  }
}

 

Luca_Carraro
12-Amethyst
(To:RPN)

Hi RPN,

sorry for my delay.

Many thanks for the solution,.

That's what I need but how do I turn it into a command,

Could it be code written inside a trail file?

I don't have these programming skills.

How you can turn it into usable code?

thank you very much for your time, many greetins, Luca.

Top Tags