Edit hole callout text via API

Programming and macros
takedownca
Posts: 5
Joined: Wed Apr 21, 2021 5:26 pm
Answers: 0

Edit hole callout text via API

Unread post by takedownca »

I can access some hole callout variables using swDisplayDimension.GetHoleCalloutVariables, but that doesn't help. What I really want is to be able to get and set hole callout text similarly to regular dimension text. But swDisplayDimension.SetText is useless on hole callouts, and I can't find any alternative. In my case, I'd like to increment the instance count on a hole callout. But I can't just grab the prefix and add "2X" to it. Because using SetText just blows away the rest of the callout text. For example, on a simple hole callout that reads "<MOD-DIAM><DIM> THRU", I can't find any method to retrieve or set that string. Thanks in advance for any help.
User avatar
bnemec
Posts: 1869
Joined: Tue Mar 09, 2021 9:22 am
Answers: 10
Location: Wisconsin USA
x 2466
x 1344

Re: Edit hole callout text via API

Unread post by bnemec »

I'm assuming you've looked at this example:
https://help.solidworks.com/2019/englis ... csharp.htm

I haven't tested this, but it feels like callouts will be different type than dimensions. From the example it looks like you want the CalloutVariable object then assuming it's a string value cast to CalloutStringVariable then you can us the String property to get the data.
takedownca
Posts: 5
Joined: Wed Apr 21, 2021 5:26 pm
Answers: 0

Re: Edit hole callout text via API

Unread post by takedownca »

Thanks for trying, but there is no special type for hole callouts. Their type is considered DisplayDimension. To get the hole callout variables you have to call swDisplayDimension.GetHoleCalloutVariables. However, the available variables are not that helpful. It's just a collection of diameters and their tolerances/precisions. There is no variable that holds the text string corresponding to what you see when manually editing the hole callout.
Post Reply