Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Hello,
I am currently building a VBA application to automate a few things in my creo daily workflow and unfortunately I am stuck because I am not able to retrieve a model type variable from a componente type feature variable. I am thinking about model descriptors. I can create it but I am struggling trying assign it to the model. The idea is to reach the model by reading the model descriptor present in the correspondent feature variable.
thank you in advance!
I’m not a VBA guru and not a VBA fan, but:
From the reference doc.
The important functions for assemblies are those that operate on the components of an assembly. The object IpfcComponentFeat, which is an instance of IpfcFeature is defined for that purpose. Each assembly component is treated as a variety of feature, and the integer identifier of the component is also the feature identifier.
Now if your feature in an assembly is from type Component, then …
The property IpfcComponentFeat.ModelDescr returns the model descriptor of the component part or subassembly.
I don’t understand that the wording is different to Toolkit, but this may part of the VBA game.
For the type it can be only Part or Assembly (Sub)
And I would NOT use this property.
The property IpfcComponentFeat.CompType returns the type of the assembly component. The component type identifies the purpose of the component in a manufacturing assembly.
You have to ask the solid about the type, if there is no function for this, compare the extension prt vs asm.
Note: A solid has sub classes like sheet metal, skeleton….
Only my 2 Cents :
set model [ps_model current]
# Get Component ID's
set CompIDs [ps_visit type -model $model component]
foreach CompID $CompIDs {
# get component name
set CompName [ps_assy component_name -model $model $CompID]
# get the extension
set ext [ps_model ext -model $CompName]
switch $ext {
PRT {
# proceed if Solid parts
}
ASM {
# proceed if Assemblies
}
default {
error "Unknow extension '$ext' in assy '$model' found"
}
}
}
Hello
Here is the code to get the Creo file name in the working folder. Please note
I created the code using AI.
Dim stringseq As Istringseq
Set stringseq = BaseSession.ListFiles("*.prt", 1, "")
Hello
It may not be the feature you want, but I'm leaving a message because I think it will be a hint
I'll send you a function that checks if the model referenced by the assembly's component is not in the session
(see blog: https://tool-2020.tistory.com/1159)
korealionkk@gmail.com