Page 1 of 1
Unable to Select and Unsuppress Center of Mass Feature
Posted: Wed Sep 27, 2023 8:52 am
by loeb
When I insert a Center of Mass feature, it ends up being suppressed in all the unactive configurations even though I have the "Suppress Feature" setting unchecked in the properties for every configuration. So, I wrote a macro that will iterate through every configuration and every feature, looking for a feature of type "CenterOfMass", then unsuppress it. The problem is that my SelectByID2 statement is returning FALSE. Here's a code snipit. Thanks for your help.
Code: Select all
While Not swFeat Is Nothing
If swFeat.GetTypeName = "CenterOfMass" Then
BoolStatus = swModelDocExt.SelectByID2(swFeat.Name, swFeat.GetTypeName, 0, 0, 0, False, 0, Nothing, 0)
BoolStatus = swModel.EditUnsuppress2()
End If
Set swFeat = swFeat.GetNextFeature
Wend
Re: Unable to Select and Unsuppress Center of Mass Feature
Posted: Wed Sep 27, 2023 9:04 am
by acmall
To give you another option you can select the Center of Mass in the Feature Tree then go to Edit - Unsuppress - All configurations
I did a quick check in SW2022 SP5.0 and I am not seeing the Center of Mass being suppressed in the non active configurations.
Re: Unable to Select and Unsuppress Center of Mass Feature
Posted: Wed Sep 27, 2023 9:34 am
by gupta9665
Try this
BoolStatus = swModelDocExt.SelectByID2(swFeat.Name, ucase(swFeat.GetTypeName), 0, 0, 0, False, 0, Nothing, 0)
Re: Unable to Select and Unsuppress Center of Mass Feature
Posted: Wed Sep 27, 2023 9:39 am
by josh
Don't use SelectByID2. SelectByID is what the macro recorder uses, but it's almost always the wrong thing to use when you're actually writing a macro. In this case, you already have a pointer to the Feature object, which has a Select2 method.
But, in fact, since you already have a pointer to the Feature object, just use the SetSuppression method of the feature. Selecting it is a waste of time because SW will take the time to update the graphics etc to show the selection.
In fact, if you use SetSuppression2 method, you can unsuppress in all configurations at once without having to cycle through.
Re: Unable to Select and Unsuppress Center of Mass Feature
Posted: Wed Sep 27, 2023 11:17 am
by AlexLachance
acmall wrote: ↑Wed Sep 27, 2023 9:04 am
To give you another option you can select the Center of Mass in the Feature Tree then go to Edit - Unsuppress - All configurations
I did a quick check in SW2022 SP5.0 and I am not seeing the Center of Mass being suppressed in the non active configurations.
He is looking to do it through API.
Re: Unable to Select and Unsuppress Center of Mass Feature
Posted: Wed Sep 27, 2023 11:58 am
by loeb
gupta9665 wrote: ↑Wed Sep 27, 2023 9:34 amTry this
UCASE? That's nuts when
swFeat.GetTypeName literally returns "CenterOfMass"
Thanks
Re: Unable to Select and Unsuppress Center of Mass Feature
Posted: Wed Sep 27, 2023 12:06 pm
by loeb
josh wrote: ↑Wed Sep 27, 2023 9:39 am
Don't use SelectByID2. SelectByID is what the macro recorder uses, but it's almost always the wrong thing to use when you're actually writing a macro. In this case, you already have a pointer to the Feature object, which has a Select2 method.
But, in fact, since you already have a pointer to the Feature object, just use the SetSuppression method of the feature. Selecting it is a waste of time because SW will take the time to update the graphics etc to show the selection.
In fact, if you use SetSuppression2 method, you can unsuppress in all configurations at once without having to cycle through.
Thanks, Josh. That works. When I find a feature of the right type, I use
BoolStatus = swFeat.SetSuppression2(swUnSuppressFeature, swAllConfiguration, Nothing)
to unsuppress it in every config all at once.
Now my problem is that this only works for preexisting COM and COMRP features. If I try to do it immediately after creating a COM or COMRP, using
Set COM = swModel.FeatureManager.InsertCenterOfMass
or
COMRP = swModel.FeatureManager.InsertCenterOfMassReferencePoint
they remain suppressed in every other configuration, even after unsuppressing them like you suggested.
I even tried rebuilding after inserting the features, but before unsuppressing them with no luck using:
BoolStatus = swModelDocExt.Rebuild(swRebuildOptions_e.swRebuildAll)
Re: Unable to Select and Unsuppress Center of Mass Feature
Posted: Thu Sep 28, 2023 6:56 am
by gupta9665
loeb wrote: ↑Wed Sep 27, 2023 11:58 am
UCASE? That's nuts when
swFeat.GetTypeName literally returns "CenterOfMass"
Thanks
Yes because recorder was spiting "CenterOfMass" as "CENTEROFMASS".
Re: Unable to Select and Unsuppress Center of Mass Feature
Posted: Thu Sep 28, 2023 9:38 am
by loeb
gupta9665 wrote: ↑Thu Sep 28, 2023 6:56 am
Yes because recorder was spiting "CenterOfMass" as "CENTEROFMASS".
I don't use the macro recorder. When I use print.debug to print the type, it was in mixed case..
Re: Unable to Select and Unsuppress Center of Mass Feature
Posted: Thu Sep 28, 2023 1:23 pm
by gupta9665
loeb wrote: ↑Thu Sep 28, 2023 9:38 am
I don't use the macro recorder. When I use print.debug to print the type, it was in mixed case..
That is correct and that is how I started to check. But when it did not worked, then I use the recorder and then found the mystery of upper case.
Re: Unable to Select and Unsuppress Center of Mass Feature
Posted: Tue Oct 03, 2023 3:29 am
by acmall
AlexLachance wrote: ↑Wed Sep 27, 2023 11:17 am
He is looking to do it through API.
Point taken!
When I read the original post I was not sure if the API route was being taken because he was not aware there is a built in option to unsuppress features in all configurations hence the suggestion. If he already knew about this well and good but I think it is always good to make sure.