Search found 16 matches

by senuba
Wed Aug 14, 2024 3:41 am
Forum: How To Questions
Topic: Automating Tree Display Settings in SolidWorks Assemblies
Replies: 6
Views: 1279

Re: Automating Tree Display Settings in SolidWorks Assemblies

I found the code :) I'm sharing it below now. Thank you everyone. 'https://help.solidworks.com/2022/English/api/sldworksapi/SolidWorks.Interop.sldworks~SolidWorks.Interop.sldworks.IFeatureManager~HideComponentSingleConfigurationOrDisplayStateNames.html 'https://help.solidworks.com/2024/English/api/s...
by senuba
Tue Aug 13, 2024 1:11 pm
Forum: How To Questions
Topic: Automating Tree Display Settings in SolidWorks Assemblies
Replies: 6
Views: 1279

Automating Tree Display Settings in SolidWorks Assemblies

Hello, I have a setting that I need to apply for every assembly. Can this be done with a macro, or is there a general setting for it? Right-click on the general assembly, "Tree Display" - "Component Name and Description," and in the window that opens, the boxes for 1-"Compon...
by senuba
Tue Jul 30, 2024 10:10 am
Forum: How To Questions
Topic: Rename From Feature Manager
Replies: 0
Views: 739

Rename From Feature Manager

Hello, I want to rename using a SolidWorks macro in the feature manager. I've enabled renaming in the settings section. I have a macro that gives me a random code. When I click on this macro while a part is open, I want it to rename the part and save it. Of course, when I say save, the part name in ...
by senuba
Tue Jul 02, 2024 9:42 am
Forum: How To Questions
Topic: Break Link From Original File
Replies: 3
Views: 1002

Re: Break Link From Original File

You are magnificent. Thank you very much.
by senuba
Tue Jul 02, 2024 9:21 am
Forum: How To Questions
Topic: Break Link From Original File
Replies: 3
Views: 1002

Break Link From Original File

Hello,
I download STEP files from websites that provide 3D CAD models. After opening these STEPs, I need to perform break link from original file for each one. I can automatically change the units, but I can't automatically break the link. Can you write and provide the code for this?
by senuba
Wed Apr 24, 2024 6:10 am
Forum: How To Questions
Topic: Finding The Body Bounding Cylinder Using VBA
Replies: 0
Views: 1444

Finding The Body Bounding Cylinder Using VBA

I have a cylindrical part. I need to find the measurements surrounding it. I will create an order measurement by adding a 5mm margin. When I run the macro on a square prism or cylindrical part, it will give the widest measurement that encompasses the part. I found something similar on a website, but...
by senuba
Wed Apr 24, 2024 5:31 am
Forum: How To Questions
Topic: Auto-Save Technical Drawings
Replies: 0
Views: 1389

Auto-Save Technical Drawings

Hello. I have a saved part file, for example "D:\part1.sldprt". I am creating a technical drawing of this part. When I save it, it asks me where to save and shows me drive D. The part is already inside D, so I'm wondering why SolidWorks is asking me this instead of directly saving it to D....
by senuba
Wed Mar 27, 2024 3:30 am
Forum: How To Questions
Topic: How to Run Macros While Closing the Solidworks)
Replies: 5
Views: 1589

Re: How to Run Macros While Closing the Solidworks)

You can't really create a macro to do this. You will just shift the problem because you will have to remember to run a macro every time you start SOLIDWORKS so that it can listen for the Destroy event and this macro would have to be pretty complicated because it has to keep track of every document ...
by senuba
Tue Mar 26, 2024 9:34 am
Forum: How To Questions
Topic: How to Run Macros While Closing the Solidworks)
Replies: 5
Views: 1589

Re: How to Run Macros While Closing the Solidworks)

SPerman wrote: Tue Mar 26, 2024 9:24 am This is an old post from the old forums.

https://forum.solidworks.com/thread/81373
Yes, I saw that page too, but I couldn't apply it. I quoted "DestroyNotify2 of PartDoc" from there. But I couldn't do it, I didn't fully understand.
by senuba
Tue Mar 26, 2024 9:16 am
Forum: How To Questions
Topic: How to Run Macros While Closing the Solidworks)
Replies: 5
Views: 1589

How to Run Macros While Closing the Solidworks)

Hello everyone, Sometimes when designing, I forget to run my important macros. Therefore, I came up with an idea and started researching: when finishing a drawing, I want a macro named Last.swp to run automatically when closing the part file. Can I do this, and do you have an example? oa I found the...
by senuba
Thu Feb 29, 2024 12:13 am
Forum: How To Questions
Topic: Body Mass in Part
Replies: 10
Views: 1801

Re: Body Mass in Part

Here's a VBA version, using PartDoc::GetBodies instead of traversing the feature tree, which shortens the code quite a bit: Option Explicit Dim swApp As SldWorks.SldWorks Sub main() Dim mDoc As ModelDoc2 Dim pDoc As PartDoc Dim mExt As ModelDocExtension Dim massProp As MassProperty Dim vBodies As V...
by senuba
Wed Feb 28, 2024 12:49 am
Forum: How To Questions
Topic: Body Mass in Part
Replies: 10
Views: 1801

Re: Body Mass in Part

Here's a C# macro that will print the mass of each body in a multi-body part: using SolidWorks.Interop.sldworks; using SolidWorks.Interop.swconst; using System.Runtime.InteropServices; using System; using System.Diagnostics; namespace BodyWeights.csproj { public partial class SolidWorksMacro { /// ...
by senuba
Tue Feb 27, 2024 8:42 am
Forum: How To Questions
Topic: Body Mass in Part
Replies: 10
Views: 1801

Re: Body Mass in Part

I could provide a note that links to the property of the body within the view it is attached to. This is how our multibody weights are displayed Edit: can't attach it so here's some images to show image.png image.png I don't want the technical drawing part. When I run the macro within the part, it ...
by senuba
Tue Feb 27, 2024 6:01 am
Forum: How To Questions
Topic: Body Mass in Part
Replies: 10
Views: 1801

Body Mass in Part

Hello, I have a body in part where I created separate bodies without using "merge the end" while extruding on a part. The weight of this part is 45kg. However, it consists of 3 different bodies weighing 10kg+15kg+20kg. How can I obtain these masses with a macro? I can retrieve the body nam...
by senuba
Fri Oct 27, 2023 1:13 am
Forum: How To Questions
Topic: Variable boolstatus for InsertMateReference
Replies: 2
Views: 913

Re: Variable boolstatus for InsertMateReference

If you want to preselect geometry and then run you macro, those lines aren't needed. Instead, you need to set the mark for each of your selections so that they have the correct values for your primary, secondary and tertiary selections. Delete those three lines and replace them with this: Dim selMg...
by senuba
Thu Oct 26, 2023 1:41 am
Forum: How To Questions
Topic: Variable boolstatus for InsertMateReference
Replies: 2
Views: 913

Variable boolstatus for InsertMateReference

Hello I've recorded a macro. It creates a Mate Reference based on selected surfaces using boolstatus. What I want is to select the surfaces by clicking and then create the Mate Reference. Since I'll be applying this to multiple parts, the constants within boolstatus need to be changed. Thank you in ...