Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Creo Parametric 9.0.4.0, OTK C++
I'm trying to assemble a component in a given assembly using csys's as references (see attached code).
What is wrong?
Here the Tcl code, check the comments, about 11 commands and the component is assembled.
I hope that helps to understand the process. You can use less than 11 lines, if you later understand what you doing here😉 You only need to map this to toolkit calls, probably > 11
# are comments
#———————————————-
# Vars for the models to be used
set ASSY assy.asm
set PART mode.prt
# Create two selection objects
# including named model items
# one for the assembly reference
# one for the component reference
# Note: The model item is initialized
ps_sel AssySelObj -modelitem AssyMiObj
ps_sel CompSelObj -modelitem CompMiObj
# A csys for sure has a name
# Note: The Feature ID of the CSYS is not the ID, which is used later
# The Geometric ID will be used
# set data, fill csys geometric id, type and owner.
#
# one for the assembly
# one for the component
# This two calls will setup the model items with valid values
# if the given name and type is valid
# the csys names are ACS0 and CS0
# now fill the modelitem by name and type
AssyMiObj byname $ASSY csys ACS0
CompMiObj byname $PART csys CS0
#
# create the constraint Object
#
ps_asmconstraint constraintObj
#
# setup the type by 'csys'
#
constraintObj config -constrainttype CSYS
#
# set the info, same as manually done in Creo after selecting the references
# Could be done in one statement as well
#
constraintObj config -asmselection AssySelObj -asmdatumside none
constraintObj config -compselection CompSelObj -compdatumside NONE
#
# Create a default matrix for initial position
#
ps_matrix matrixObj
#
# Assemble the component first without any constraints
# You only have to take care that
# 'PlacedMiObj' does not exists as a command with another type.
# You can create it upfront as well, same for the Matrix Object
#
ps_assy assemble -model $ASSY -- $PART matrixObj PlacedMiObj
# Final call to set the constraints
# We don't need to specify a component path in this sample
# The path argument are not given to the function
# because we assemble to the toplevel csys of the assembly and we assemble a single component
# 'PlacedMiObj' is the result from assembling without constraints
# this uniquely identifies the component to configure
# 'list' is used to keep in mind that you may need to specify more the one constraint
# If you assemble by datum planes you need to supply normally 3 constraints
#
# If this fail, you may want to delete the placed component with ps_feat delete ?ID?
# The feature id you get with: 'PlacedMiObj cget -id'
#
# Configure the placed component to make if fully parametric
#
ps_assy setconstraints PlacedMiObj [list asmconObj]
# Component is now fully constraint and assembled by csys
#———————————————-
Hi,
thx for your tcl listing. I guess I have done all this in my listing as well, but I always get the message below:
pfcExceptions::XToolkitInvalidReference
{
Message : "Assembly reference must have Assembly Component Path"
MethodName : "pfcComponentFeat_tk::SetConstraints"
}
Therefore i'm not sure if I have done everything correct!
For the simplest case, assembly a component at csys from the target assembly, you may have to setup table_num and comp_id_table to -1 if you don‘t use NULL for the CompPath in the selection reference..
Check how you setup the selection, you can init this one as well only with a modelitem.
If you want to assemble the component and use a csys in the tree structure, you must supply the comppath to this model, and the model handle in assembly selection.
there is a sample code in protk_appls\pt_examples\pt_asm\TestAsm.c in protoolkit installation folder. Probably this is what you are looking for...