Scale parts in assembly (VBA)

Hi,

Following my situation: I created an assembly containing 7 parts. These are linked correctly.

Every part contains the feature scale (uniform scaling around origin).

If I want to scale up/ down the parts, I proceed like open edit component mode, edit feature, enter the new value, confirm and close the edit mode and rebuild the model.

For my purpose i want to do this fully automated with vba.

Is there a way how i can access the feature and edit the values using vba?

Trying to record a macro resulted in:

boolstatus = Part.Extension.SelectByID2("scale1@part_name@assemlby_name", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)

Part.ClearSelection2 True

boolstatus = Part.EditRebuild3()

My problem is, that setting a value is not possible.

Thanks for your help.

SolidworksApi/macros
Answers 4
JB
JB 2021-04-09 Best Answer

Hi Bernhard,

I have good news and bad news for you.

Unfortunately, I will tell you the good news first.

Yes, this is totally possible within the API.

Now the bad news:

This is well beyond the capabilities of the macro recorder.

There is an example in the API help that shows how to get the scale information:

2018 SOLIDWORKS API Help - Get Data for Scale Feature Example (VBA)

Unfortunately, you'll need a lot more code to be able to run a macro from the assembly and have all parts scale update.

Someone may write this for you... We shall see!

JS
JS 2021-04-09

- Understood, but I wrote that with a twinge or a dash of envy.. For guys like you it is easy, but for some of us, not so... Appreciate what you've done over the years for the community

JB
JB 2021-04-09

Unfortunately, not so many people are interested in the cha ching part... I'm certainly available for that though! Sometimes macros are interesting and/or challenging or pique my interest (like the recent one about linking notes to assembly properties). After having written a few hundred, interesting and challenging ones are further and further apart...

JS
JS 2021-04-09

- You're a "Macro Writer Guru Extraordinaire" cha ching ca ching