Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
The variable text in symbol instants does not change from the preset value.
The value in the instruction is set to the new value.
What is needed to get the text in the symbol changed?
public static void placeKPCInst(Point3D point, Integer kpc) {
try{
DetailSymbolDefItem symDef = drawing.RetrieveSymbolDefinition ("PWI-04-02-06_kpc_diamond", null, null, false);
DetailSymbolInstInstructions instrs = pfcDetail.DetailSymbolInstInstructions_Create (symDef);
String variableText = "" + kpc;
DetailVariantTexts varTexts = DetailVariantTexts.create();
DetailVariantText varText = pfcDetail.DetailVariantText_Create("VAR_TEXT" , variableText );
varTexts.insert(0,varText);
instrs.SetTextValues(varTexts);
// instrs.GetTextValues().get(0).GetValue(); returns the KPC value
// Set the location of the note text
FreeAttachment position = pfcDetail.FreeAttachment_Create (point);
DetailLeaders allAttachments = pfcDetail.DetailLeaders_Create ();
allAttachments.SetItemAttachment (position);
instrs.SetInstAttachment (allAttachments);
// * Create and display the symbol
DetailSymbolInstItem symInst = (DetailSymbolInstItem) drawing.CreateDetailItem (instrs);
symInst.Show();
}
Solved! Go to Solution.
I solved the problem
Changing the variable text on instants creation does not work.
Create the instant and get DetailSymbolInstInstructions from instant.
change the text value and modify instant with the new instructions.
DetailSymbolInstItem symInst = (DetailSymbolInstItem) drawing.CreateDetailItem (instrs);
DetailSymbolInstInstructions ins; // cant use old instructions intrs
ins = symInst.GetInstructions(true);
ins.GetTextValues().get(0).SetValue(variableText); |
symInst.Modify(ins); | |||
symInst.Show(); |
I solved the problem
Changing the variable text on instants creation does not work.
Create the instant and get DetailSymbolInstInstructions from instant.
change the text value and modify instant with the new instructions.
DetailSymbolInstItem symInst = (DetailSymbolInstItem) drawing.CreateDetailItem (instrs);
DetailSymbolInstInstructions ins; // cant use old instructions intrs
ins = symInst.GetInstructions(true);
ins.GetTextValues().get(0).SetValue(variableText); |
symInst.Modify(ins); | |||
symInst.Show(); |