Skip to main content
12-Amethyst
August 29, 2016
Solved

The variable text in symbol instants does not change from the preset value.

  • August 29, 2016
  • 1 reply
  • 1617 views

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();

   }


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
Best answer by pgalens

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();

1 reply

pgalens12-AmethystAuthorAnswer
12-Amethyst
August 30, 2016

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();