I have a spreadsheet that changes dimensions of models. I want to be able to select different standard holes from a list, manipulating the hole wizard, instead of just changing the dimensions.
The hole is a feature on a model. If I have the model open, it works wonderfully. What I want to do is have the assembly open and change the feature without having to open the model. Currently if I try running the program as is, the SelectByID2 command returns a false value.
Thank you,
Scott
SolidworksApi macros
Hi Scott,
in my opinion the ComponentName in incomplete,
You should use the API GetNameForSelection Method (IFeature)
to retrieve the full name of the feature in assembly.
Roberto
Roberto,
Thank you very much for your reply. I don't think I am understanding how to use that method. I tried adding the lines:
Dim featType As String: Dim featName As String
If simplePart.selectionmanager.getselectedobjectcount = 1 Then
'get the feature definition using .getdefinition
Set feature = simplePart.selectionmanager.getselectedobject6(1, -1)
featName = feature.GetNameForSelection(featType)
but getselectedobjectcount is always zero, so the program never gets this far.
I agree that I must be addressing the feature incorrectly. Do you know what format the full component name should be in. The program currently uses the format feature@componentName.sldpart
Thank you again,
Scott
Hello Scott,
uses this example for your application, it should be the one that's right for you.
2016 SOLIDWORKS API Help - Get Feature Type and Name Example (VBA)
Thanks
Roberto