Skip to main content
4-Participant
February 18, 2025
Question

VARIABLE TEXT IN CUSTOM SYMBOL c++ code

  • February 18, 2025
  • 2 replies
  • 967 views

Hi I want to add variable text to a custom symbol programmatically.

2 replies

Community Moderator
February 18, 2025

Hello @RD_12909834

 

Thank you for your question


I'd like to recommend to bring more details and context to your initial inquiry. 

  1. Have you already tried any methods or approaches to add variable text to the custom symbol using C++? If so, what were the results? 
  2. Are you encountering any specific error messages or issues when trying to implement this feature?

It also helps to have screenshot(s) to better understand what you are trying to do in your process. Adding more context will increase your chances to receive meaningful help from other Community members. 

Regards,
Vivek N
Community Moderation Team.

4-Participant
February 18, 2025

Hi,

This is my code and it is not giving any error but not updating the

// load symbol file
pfcDetailSymbolDefItem_ptr symDef = pfcDwg->RetrieveSymbolDefItem("dim_balloon", pfcDetailSymbolDefItemSource::pfcDTLSYMDEF_SRC_PATH, strr, NULL, true);
pfcDetailSymbolInstInstructions_ptr instrs = pfcDetailSymbolInstInstructions::Create(symDef);
 
pfcDetailVariantText_ptr mtext = pfcDetailVariantText::Create("inValue", xstring::Printf("%d", k + 1));
dims = dimname.c_str();
 
pfcDetailVariantTexts_ptr stext = pfcDetailVariantTexts::create();
stext->append(mtext);
 
pfcFreeAttachment_ptr freeAttachmentpos = pfcFreeAttachment::Create(src_loc);
pfcView2D_ptr view2d;
view2d = pfcView2D::cast(model2D->GetViewByName("Primary View"));
 
freeAttachmentpos->SetView(view2d); // #
freeAttachmentpos->SetAttachmentPoint(src_loc);
pfcAttachment_ptr attach = pfcAttachment::cast(freeAttachmentpos);
instrs->SetInstAttachment(pfcSymbolDefAttachmentType::pfcSYMDEFATTACH_FREE);
instrs->SetTextValues(stext);
 
Regards
4-Participant
February 18, 2025

This is not updating the symbol note

24-Ruby III
February 18, 2025

Hi,

contact PTC Support.