Simplified macro assembly without screws

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

Yes @remrem I saw that in the meantime, I had the 2019 I just uninstalled it and installed the 2015 and it works perfectly now, I can edit from Solidworks and therefore debug.

For the desired changes as mentioned in my previous message:

- Create the configuration if and only if certain IsToolboxStandard component is present and if the "Category" property of the assembly is "Assembly"

- Process the open assembly and all the subassemblies concerned (according to the above criteria)

- Modify all subassembly configs by the simplified "Fastener enabled" config only in the simplified config of the main assembly "Fastener enabled", but not in the default config which must remain as is.

I'm starting to discover macros via Visual Studio and it seems very promising to me, even if I don't understand the whole thing yet!

For point 2 I just saw that I have a mistake: The class does not have a license to use.

Maybe I didn't stick the right key?

Can it be changed?

What should be pasted in the email received a key of this form (change the numbers by 0s for confidentiality):

swdocmgr_general-000000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-0000-0,swdocmgr_previews-000000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-000 swdocmgr_dimxpert-000000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-0000-0,swdocmgr_geometry-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-0000-0000-0000-0000-0000-0000-0000-0000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00 swdocmgr_xml-000000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000 swdocmgr_tessellation-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-00000-00000-00000-0000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-0

 

For my part I pasted this:

swdocmgr_general-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-0000-00000-0000-00000-00000-0000-0000-00000-00000-0000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-0000

I made the macro store its settings in an Xml file located in this folder: C:\Users\UserName\AppData\Local\Suppression_visserie

The file is composed as follows:

<?xml version="1.0" encoding="utf-8"?>
<Parametres xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Version>1.0.0.0</Version>
  <DocMgrLicence>NomEntreprise:swdocmgr_general-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-000000-00000-000,swdocmgr_xml-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-00000-000</DocMgrLicence>
</Parametres>