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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

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

pgalens
11-Garnet

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

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.
1 ACCEPTED SOLUTION

Accepted Solutions
pgalens
11-Garnet
(To: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();

View solution in original post

1 REPLY 1
pgalens
11-Garnet
(To: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();
Top Tags