Search found 30 matches

by Stefan Sterk
Tue Jan 30, 2024 4:24 pm
Forum: API
Topic: WasResolved from Get6 (CustomPropertyManager)
Replies: 4
Views: 673

Re: WasResolved from Get6 (CustomPropertyManager)

I also tried to imitated these conditions, and also got only TRUE values for WasResolved, since the value cleary wasn't as is shown in the attached image below. Using SOLIDWORKS 2023. image.png Used the code below to create the resultes in immediate windows. Option Explicit Sub main() Dim swApp As S...
by Stefan Sterk
Tue Jan 30, 2024 4:48 am
Forum: API
Topic: macro features: what are they for?
Replies: 6
Views: 747

Re: macro features: what are they for?

Hi mp3-250 , There are a few examples on codestack.net Macro Feature - Add Watermark Feature - Model Configurator - Link And Auto Update General Table To Excel - Generate Box Geometry - Link Cut-List Custom Properties To File Custom Properties - Automatically Run Macro On Model Load - Create MultiBo...
by Stefan Sterk
Fri Jan 26, 2024 5:08 pm
Forum: Macro Library
Topic: Creat a Macro to Add colors to each feature in a a part
Replies: 4
Views: 953

Re: Creat a Macro to Add colors to each feature in a a part

Hi Craig, the code below will give a unique color to each component in a assembly. Thought I'd drop it here since you asked about it in our PMs. ' ################################################### ' # Title: Random Colorize Components # ' # Version: 24.1.26 # ' # Author: Stefan Sterk # ' #########...
by Stefan Sterk
Sat Jan 13, 2024 12:42 pm
Forum: API
Topic: Macro to find all files created in a given version
Replies: 9
Views: 1094

Re: Macro to find all files created in a given version

As gupta said, the code of artem will fit your need, straid out of the box.

Got some other info. The index for 'Last Saved With SW' doens't seems to be contant. On my Windows 11 system is is set on 330 instead of 336 (Windows 10). Not sure if it is Windows related or user setting.
by Stefan Sterk
Fri Jan 12, 2024 3:02 am
Forum: API
Topic: Macro to find all files created in a given version
Replies: 9
Views: 1094

Re: Macro to find all files created in a given version

Tera wrote: Thu Jan 11, 2024 8:09 pm I haven't reviewed @artem code yet, but your code returns null values.
What does 336 stands for?

Thanks.
336 is the index for 'Last Saved With SW' extended file attribute/detail. A value that can be shown in the file explorer. See image below. This is working for me
image.png
by Stefan Sterk
Thu Jan 11, 2024 4:59 am
Forum: API
Topic: Macro to find all files created in a given version
Replies: 9
Views: 1094

Re: Macro to find all files created in a given version

Hi Tera, Have a look at https://www.codestack.net/solidworks-api/document/versions-report/ artem code used the solidworks application to get the version history. Which limits the speed. A faster way is to get the file atribute 'Last Saved With SW' itself, see example code below Sub main() Debug.Prin...
by Stefan Sterk
Thu Nov 23, 2023 7:09 pm
Forum: Macro Library
Topic: Creat a Macro to Add colors to each feature in a a part
Replies: 4
Views: 953

Re: Creat a Macro to Add colors to each feature in a a part

Hi Craig Makarowski , See code below. 2023-11-24-01-16-35.gif Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swDoc As SldWorks.ModelDoc2 Dim swFeat As SldWorks.Feature Dim R() As Double, G() As Double, B() As Double Dim vMatVal(8) As Double Dim i As Long: i = -1 Set swApp = Applicatio...
by Stefan Sterk
Thu Nov 23, 2023 11:50 am
Forum: Macro Library
Topic: Reset Light Sources
Replies: 3
Views: 701

Reset Light Sources

Here is a simple macro which gives you the power to easily reset your light sources within a SOLIDWORKS Part or Assembly model by deleting the current light sources and adding back the 'default' (user specified) light sources. Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As ...
by Stefan Sterk
Thu Nov 16, 2023 3:55 pm
Forum: Macro Library
Topic: Save PDF and SLDDRW at same time
Replies: 2
Views: 590

Re: Save PDF and SLDDRW at same time

Awesome Stuff @xitter. Keep up the work!

I noticed that there are a few lines you should remove at the start.
image.png
by Stefan Sterk
Thu Nov 02, 2023 4:35 am
Forum: Macro Library
Topic: My Macros
Replies: 16
Views: 5932

Re: My Macros

mme wrote: Tue Oct 24, 2023 9:42 am Open part or assemblies. Run the macro. Enter a new name. If there is a drawing, it will put the same name on the drawing.
Hi @mme,
Sounds the same as this macro; https://www.codestack.net/solidworks-ap ... t-drawing/
by Stefan Sterk
Mon Oct 09, 2023 2:49 pm
Forum: API
Topic: Multi Export Assembly and Parts with Structure
Replies: 2
Views: 521

Re: Multi Export Assembly and Parts with Structure

Hi Mmike4 Here is a example on how you could get the name without the instance ID. Copy component name to the component reference using SOLIDWORKS API (codestack.net) '********************** 'Copyright(C) 2023 Xarial Pty Limited 'Reference: https://www.codestack.net/solidworks-api/document/assembly/...
by Stefan Sterk
Wed Sep 13, 2023 6:03 am
Forum: API
Topic: Macro throwing error
Replies: 9
Views: 873

Re: Macro throwing error

I believe the selected component is Ligthweight, which will throw an error when pulling the custom properties.
by Stefan Sterk
Thu Aug 31, 2023 6:14 am
Forum: API
Topic: What is the image size for the macro button?
Replies: 16
Views: 2021

Re: What is the image size for the macro button?

Codestack.net also says to use 20x20px for SOLIDWORKS newer then 2015. "Optionally specify the icon. For SOLIDWORKS 2015 or older use 16 by 16 bitmap, for all newer version use 20 by 20 bitmap. Use white color as the transparency key." SOLIDWORKS icon size on macro features also starts at ...
by Stefan Sterk
Wed Aug 09, 2023 3:51 am
Forum: API
Topic: Macro to adjust the partnames in a STEP export
Replies: 5
Views: 1088

Re: Macro to adjust the partnames in a STEP export

Rather than muck around with temporarily renaming things, you can simply post process the STEP file. It's text after all. The components are identified by the name followed by an underscore and then the configuration name. If you use C# or VB.NET you have a Regex.Replace method you can use to prepe...
by Stefan Sterk
Tue Aug 08, 2023 11:33 am
Forum: API
Topic: Macro to adjust the partnames in a STEP export
Replies: 5
Views: 1088

Re: Macro to adjust the partnames in a STEP export

simple answer, yes you can. check Name2 . 1. open assembly 2. traverse through components 2.a rename component with Name2 . 2.b list comp in already renamed list 3.SaveAs (Export) 4.close assembly without saving. aslong as you dont save the document(s) the name changes wil only be in memory. other l...
by Stefan Sterk
Tue Jun 20, 2023 7:53 am
Forum: API
Topic: Save As 3mf macro
Replies: 8
Views: 917

Re: Save As 3mf macro

Does using the SaveAs3 method from IModelDocExtension give a different result?
by Stefan Sterk
Wed Nov 16, 2022 5:21 am
Forum: API
Topic: using openDoc6 browse for missing file.
Replies: 4
Views: 698

Re: using openDoc6 browse for missing file.

Hi colt , Replace swOpenDocOptions_e.swOpenDocOptions_Silent with Empty or -1 . swOpenDocOptions_e.swOpenDocOptions_Silent suppresses the warning dialogs like missing file. Set res = swApp.OpenDoc6(fileP , swDocumentTypes_e.swDocDRAWING, Empty, "", err, warn) Instead of Set res = swApp.Ope...
by Stefan Sterk
Sun Oct 30, 2022 6:11 pm
Forum: SW General
Topic: What is the most efficient way to see where a file is saved?
Replies: 11
Views: 742

Re: What is the most efficient way to see where a file is saved?

I got this macro (Code below) that opens the file location in the Windows Explorer for the selected component. Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swSelMgr As SldWorks.SelectionMgr Dim swComponent As SldWorks.Component2 Dim Path As String S...
by Stefan Sterk
Thu Sep 29, 2022 11:19 am
Forum: API
Topic: Change custom properties without opening the component from the drawing?
Replies: 7
Views: 1707

Re: Change custom properties without opening the component from the drawing?

Yes you can. I got a macro that give me the ability to change the properties of a compenent that is selected in a drawing BOM.
by Stefan Sterk
Wed Aug 10, 2022 5:16 am
Forum: SW General
Topic: What should the behavior of ‘Dissolve part level rows’ be?
Replies: 1
Views: 1818

What should the behavior of ‘Dissolve part level rows’ be?

I made this post to express my dissatisfaction with how Solidworks and our VAR are handling this, and I'd like to hear your thoughts. I mean, is it just me? () So Solidworks introduced the ‘ Dissolve part level rows ’ option under ‘Detailed cut list’ in the bill of materials (BOM) options for Solidw...
by Stefan Sterk
Fri Jul 08, 2022 6:22 am
Forum: API
Topic: Macro to Mate Origin - Origin
Replies: 5
Views: 1211

Re: Macro to Mate Origin - Origin

I contacted API Support and they suggest using AddMate5 with swMateCOORDINATE, which will align the axes. The code snippet below works as expected. Have fun with it ;) Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swAsm As SldWorks.AssemblyDoc Dim swSelMgr As SldWor...
by Stefan Sterk
Fri Jul 08, 2022 3:44 am
Forum: API
Topic: Macro to Mate Origin - Origin
Replies: 5
Views: 1211

Re: Macro to Mate Origin - Origin

Hi Zhen, The code that follows fulfills your request. The only issue I can identify is that the Origin Axes don't align as they would if I did it manually. grumph Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swAsm As SldWorks.AssemblyDoc Dim swSelMgr As SldWorks.Se...
by Stefan Sterk
Sat May 21, 2022 4:25 pm
Forum: API
Topic: How to skip identical parts with GetComponents
Replies: 3
Views: 758

Re: How to skip identical parts with GetComponents

I start by making a list of unique components and then loop through it. as demonstrated by the code below Option Explicit Sub main() Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swUniqueCompList() As SldWorks.Component2 Dim swComp As SldWorks.Component2 Dim vComp As Variant S...
by Stefan Sterk
Sun Feb 13, 2022 2:14 pm
Forum: API
Topic: Bug? Units VBA macro turns on Scene Reflections and Shadows
Replies: 4
Views: 936

Re: Bug? Units VBA macro turns on Scene Reflections and Shadows

I'm running SW2021 SP5.1 and i do get the same behavior, and not just with the API calls, it also happens when just going to ⚙️ Options and click ing on the OK button does enable the floor shadow and reflection on none active configurations. ChangingDocumentPropertiesEnablesFloorShadowForNoneActiveC...
by Stefan Sterk
Sun Oct 10, 2021 10:30 am
Forum: Macro Library
Topic: Need macro to export to 2 diffrent locations
Replies: 10
Views: 3208

Re: Need macro to export to 2 diffrent locations

Why would you perform the export twice and not just copy paste the file that you have exported with the FileCopy function? FirstPathName = FilePath & SaveFileName & "-" & Rev & ".STEP" SecondPathName = FilePathDump & SaveFileName & "-" & Rev ...
by Stefan Sterk
Fri Oct 08, 2021 6:40 am
Forum: Macro Library
Topic: Body names from a PRT
Replies: 7
Views: 2219

Re: Body names from a PRT

The code below will put the bodies in a cut-list and add a custom property with the name of the body. Which you can link to a drawing note. And it also change the name of the cutlist folder to the name off the body with an extra space at the end. Let me know how it goes. Option Explicit ' Name of th...
by Stefan Sterk
Thu Oct 07, 2021 12:59 pm
Forum: Macro Library
Topic: Body names from a PRT
Replies: 7
Views: 2219

Re: Body names from a PRT

Hi Peter, Have you tried making a Cut-List by going to the Weldments tab and then clicking on the Weldment command. image.png You can then add properties to the cut list item, a partname for example. image.png image.png Which then can be linked to the drawing notes. image.png I believe there are som...
by Stefan Sterk
Tue Sep 07, 2021 9:23 am
Forum: Macro Library
Topic: Open Drawing From BOM
Replies: 19
Views: 2999

Re: Open Drawing From BOM

Hey Stefan! I am using Resolved, but my SolidWorks is in french rather then english. Could that be the cause? This is the error I get on Visual Basic. 2nd image to show how I selected. 3rd image to show file location. image.png image.png image.png language shouldn't be the issue. That error you get...
by Stefan Sterk
Mon Sep 06, 2021 8:03 am
Forum: Macro Library
Topic: Open Drawing From BOM
Replies: 19
Views: 2999

Re: Open Drawing From BOM

Hi Stephan, I've followed the instructions in your video, but nothing happens when I use the mouse gesture; no feedback of any sort. The drawings are in the same directory as the models and the filenames are identical. Any suggestions? Thanks Stefan, I've downloaded the macro and shared it with my ...
by Stefan Sterk
Tue Aug 10, 2021 3:06 am
Forum: Macro Library
Topic: Open Drawing From BOM
Replies: 19
Views: 2999

Open Drawing From BOM

Well Hello, For those who wanna open a drawing directly from another drawing BOM. Stop searching for a solution because this post will give you on. Happy reading, wachting and opening drawings. Note: The drawings needs to be in the same folder and having the same filename as the part/assembly you wa...