Ok.
I don't see it on my test file, maybe because it happens too quickly.
It might come from the GetItems function, but I don't see any other way to check if the layer is empty.
Maybe I didn't understand your requirement correctly.
When you say "unused layers", I assumed it was "layers that don't have any items on them".
Is it "layers that are hidden" instead? Something else?
I also don't quite understand the problem with: "but also turns on items on layers".
Try this:
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swLayerMgr As SldWorks.LayerMgr
Dim vLayers As Variant
Dim vLayer As Variant
Dim swLayer As SldWorks.Layer
Dim vItems As Variant
Set swApp =...
InsertBomTable4 didn't work for some reason and so swBOMAnnotation is Nothing which cause the error later
check that :
- "C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\lang\english\bom-standard.sldbomtbt" actually exists
- swView is not nothing with: If swView Is Nothing then Msgbox("View is...
This will give each body a random color and put them in a folder
Option Explicit
Dim xlApp As Excel.Application
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
SetWeldmentParams...
If you color every bodies differently, you should create a new feature for each. Then apply the color either to the feature or its body, before looping to the next line.
To move the bodies to a cut list folder, you can use MoveToFolder
For the color, the best way would be to apply the color to the Structural Member Feature:
Sub ApplyColor(swModel As SldWorks.ModelDoc2)
Dim vProp As Variant
Dim swFeat As SldWorks.Feature
Set swFeat =...
Try this:
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSketch As SldWorks.Sketch
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSketch = CreateSketch(swModel)
CreateWeldment swModel, swSketch...
Hello,
Select some components in the selection tree, then run the code below.
It will give their name in the order of the selection.
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swSelComp As...
Interesting.
Just my 2 cents: I feel like it would be easier to bent and fit between the vertical cylinders if the faces were flat. And easier to weld if those faces were perpendicular to the cylinders faces. That would also avoid the side faces to go to infinity if the horizontal cylinder...
Hello,
Only the material is saved in the file.
The density, associated with this material, is stored in the material database.
Try the following code.
Note: go to Tools > Reference and add "Microsoft XML, VX.X"
Option Explicit
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As...
Hello,
You can use GetWhatsWrongCount Method to get the number of build errors.
And GetWhatsWrong Method to get details on each error.
Those methods can be used in a third party command line application, but Solidworks need to be installed to open the document.
You can auto-generate the drawing of each individual body with macro. I've done it for a client.
I don't know what "Keeping track of similar items" entails, but you might do that with macro too.