Skip to main content
4-Participant
Feb 18, 2025 6:35 AM UTC
Question

VARIABLE TEXT IN CUSTOM SYMBOL c++ code

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

5 replies

Community Moderator
Feb 18, 2025 6:57 AM UTC

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.

Translate
4-Participant
Feb 18, 2025 7:12 AM UTC

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
Translate
4-Participant
Feb 18, 2025 7:13 AM UTC

This is not updating the symbol note

Translate
24-Ruby III
Feb 18, 2025 7:49 AM UTC

Hi,

contact PTC Support.

Translate