Page 1 of 1

Edit hole callout text via API

Posted: Wed Apr 21, 2021 5:41 pm
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.

Re: Edit hole callout text via API

Posted: Wed Apr 21, 2021 6:11 pm
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.

Re: Edit hole callout text via API

Posted: Wed Apr 21, 2021 6:26 pm
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.