Simplified macro assembly without screws

Hello

A few years ago I was shown a macro to simplify an assembly.

This macro that was launched from an assembly created a "Simplified" or "Fastener" config (I don't remember the name, in which all the screws had gone to the deleted state (ISfastener=1)

And the same thing in all the sub-assemblies of the main assembly.

This allowed me to have a lighter configuration (without the screws of a complex assembly) so that it could be inserted into my layout afterwards.

Does anyone have a macro to share that comes close to this request?

Otherwise I'll have to try to find time to rewrite it, even if it seems a bit complex to me with my limit level in SW coding.

Hello @sbadenis 

if you manage to do it I'd be interested in such a macro: either to be able to simplify in Motion, or to simplify in Simulation

Kind regards

 

2 Likes

Interesting.

It's clear that it must be a bit of a mess, since you also have to go into the repetitions and remove the components but not the repetition.

1 Like

Wouldn't it be the "defeature" option that simplifies a geometry? (Defeature - 2022 - SOLIDWORKS Help)

1 Like

@mdelbecq, yes deafeature allows you to simplify an assembly by creating a simplified copy in one piece.

Here the goal is to keep the same assembly, with a lighter configuration without the screws.

The goal is to make layouts with a lot of machines, and by lightening the assembly a little thanks to this configuration.

Deafeature has been tested and works but it takes at night or more to get something correct, compared to several machines, it becomes impossible.

Hence the demand for macro.

1 Like

Hello;

Why don't you go through the "Smart Playlists"?
-> Advanced Component Selection / Set Search Criteria....
https://help.solidworks.com/2021/french/SolidWorks/sldworks/t_utilities_running_power_select.htm


With the ISfastener Filter=1
It's simpler, isn't it?
Especially since you can combine several Filters, reverse them or cancel them. (And Save them too...)

Kind regards

3 Likes

Hello dear @Maclane

This implies that the screws come from the toolbox.

Most of the time I download screws (often in step by the way) and I have more than doubts that SW recognizes them as washer screws or bolts.

How to declare this type of part so that they are identifiable by SW as bolts and screws    ;-)

I suspect that @sbadenis must not have this type of question;-) ;)

Kind regards

2 Likes

Your @Maclane  solution actually works very well when all the screws are in the head assembly.

The problem is that I have screws in a lot of sub-assemblies, and I have to keep these screws in the default config so that the (screw) orders are switched to automatic when launching.

The only way is to do this damn macro.

After for the macro, the filter solution may be to be considered.

1 Like

Hello

The Maclane solution is interesting.

I use a similar methoid:
-I create a "Light" configuration
-I use the "S" key, then select toolbox, I hold "Ctrl" + right click on a screw -> Delete

This gives me 2 configurations, one of which is without screws...

A+

1 Like

@Zozo_mp: the part does not need to be from the toolbox. It just needs to contain the ISfastener property

I had set this up when we created our screws database in 2005 (totally different from the Toolbox) and it works perfectly.

Thank you @Maclane who allowed me to discover (or rediscover) this selection tool which is all in all ultra powerful.

3 Likes

Thank you @froussel I'm going to look at this closely, I feel like it's going to save me time with the new screw assembly features since SW2020.

Kind regards

Zozo_mp : 2015 for this "New" function (Solidworks doesn't communicate very well about their new features... useful)
As for the horrible ToolBox (Yuck) I never use it (Except to create holes/taps/lights... can be used with the drilling wizard).
I created my own custom libraries (with the IsFastener property set to 0 or 1).


-> FYI: this Property (IsFastener) is the one used for drawing  sections or for collision detection (option: Exclude bolts).
sbadenis : The use of Macros seems indeed inevitable to create each "Lite" configuration of all Subassemblies...
(The VBA function is: "PowerSelec" for Smart Selection but for now I don't know more -sorry-

Solidworks Help (API)- > https://help.solidworks.com/...Interop.gtswutilities.IUtilities~PowerSelect.html


Kind regards.

4 Likes

Hi everyone,
I made a macro that creates a configuration without screws for the assembly and its sub-assemblies.

For it to work, it is necessary to use the Document Manager APIs. In particular to read the invisible property "IsToolboxStandard" allowing you to define whether the part is a screw. A license is requested at the first launch. To obtain this license, you must apply for it through the SolidWorks Customer Portal, following these procedures :

To request a SOLIDWORKS Document Manager API license key:

  1. Log into the SOLIDWORKS customer portal.
  2. Click API Support in My Support
  3. Click Document Manager Key Request.
  4. Follow the online instructions to request your license key.

A SOLIDWORKS Document Manager API license key is emailed to you upon approval of your request.  

 

It works with Toolbox components and custom libraries whose components have the "IsToolboxStandard" property.

You can add this property easily with the utility provided for this purpose: "sldsetdocprop.exe" located in the folder: "C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\Toolbox\data utilities"

 

I invite you to test the macro on test assemblies and give me your feedback.

Have a nice day.


suppression_visserie.zip
2 Likes

Key request made, all you have to do is wait for the email.

On the other hand, I don't really know the principle to launch a vb project in this form (via Visual Studio)

For a macro in vba no worries, I'm starting to know.

But in this form, I admit that I installed Visual Studio 1 or 2 years ago without ever having taken too much time to go deeper.

To open the project no worries, but how to launch the program? I think I'll need a little extra help @remrem  if you don't mind.

And if you have a help site in addition it would be great.

Otherwise the code seems not bad to me at all after a quick read, just wait for this famous code!

You fill in the macro button as for a file in .swb format except that you choose the dll format:

Then you click browse and you change the type by selecting "SW VSTA Macros (*.dll)" and you choose the file "Suppression_visserie.dll"

3 Likes

Hello
Does it work?

1 Like

Thank you @remrem, I just tested after a few problems to get the famous key.

The email was going to Spam, I had to do it on my personal mailbox, and wait a few days...

Except for the operation, now that I have been able to test! This is very close to my need, thank you for this very good base.

The configurations are well created for all assemblies.

On the other hand, in these configurations, the screws are not removed (even if the ISFastener option is set to 1)

Also, I would like it to create the configuration only if the assembly contains screws with ISFastener=1 and a "Category" property is "Assembly".

In subassemblies, the active configuration remains default instead of Fasteners enabled in the fasteneres enable configuration of the main assembly.

I'd try some modifications in the code which is a very good base, to improve it in my own way, but I've always developed via VBA macros (without going through dlls) and I don't know how to debug if possible via visual studio to see where it gets stuck and see the changes live if possible.

Do you have to compile the project to test it later?

Can we execute step by step and see where it gets stuck?

 

 

Be careful, there is a mistake.
The "IsFastener" property is only used to hide the fasteners in the MEPs.
The macro doesn't use this property but as I indicated in my previous post:

It works with Toolbox components and custom libraries whose components have the "IsToolboxStandard" property.

You can add this property easily with the utility provided for this purpose: "sldsetdocprop.exe" located in the folder: "C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\Toolbox\data utilities"

 

The "IsToolboxStandard" property is hidden. Therefore, it is not visible in the SolidWorks Property Editor. That's why I had to use the Document Manager library.

2 Likes

Indeed @remrem, there was a mistake, I will look at how to improve the project which is a very good basis. Can you answer me if you have some time on the method used to compile and debug projects via a dll.

Since you joined the entire project with a little time and work, I should eventually succeed in modifying this  project for my usefulness.

Hi sbadenis,

SolidWorks is only compatible with Visual Studio 2015. Look here.

What changes do you want?

1 Like