Hello
we are required to work on assemblies extracted from STEP or IGES files.
By default, parts, assemblies, and sublevels are free.
Do you or do you know a quick way to fix all the components of the main assembly.
Thank you.
Davy
Hello
we are required to work on assemblies extracted from STEP or IGES files.
By default, parts, assemblies, and sublevels are free.
Do you or do you know a quick way to fix all the components of the main assembly.
Thank you.
Davy
Hello
Try this:
Option Explicit
Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swAssy As SldWorks.AssemblyDoc Dim swModelDocExt As SldWorks.ModelDocExtension Dim swComp As SldWorks.Component2 Dim swSelMgr As SldWorks.SelectionMgr Dim errors As Long Dim warnings As Long Dim status As Boolean
Sub main()
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swAssy = swModel Set swModelDocExt = swModel.Extension Set swSelMgr = swModel.SelectionManager
' Resolve all lightweight components errors = swAssy.ResolveAllLightWeightComponents(True) Debug.Print ("All lightweight components resolved (0 = All components resolved)? " & errors)
' Fix the selected component status = swModelDocExt.SelectByID2("Pad_1-1@key pad_1", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0) swAssy.FixComponent status = swModelDocExt.SelectByID2("Pad_1-1@key pad_1", "COMPONENT", 0, 0, 0, False, 0, Nothing, 0) Set swComp = swSelMgr.GetSelectedObjectsComponent3(1, -1) Debug.Print ("Selected component fixed?" " & swComp.IsFixed)
End Sub
Sources: http://help.solidworks.com/2015/english/api/sldworksapi/resolve_all_components_fix_a_component_example_vb.htm
Edit: I'm attaching the txt file because the presentation is automatically deleted
Hello
Is it possible as an attached document, with right click and "fix" all the elements!?
Thanks remrem, I'll try.
The problem, drawing6, is that this manipulation does not allow us to fix the sub-levels. But thank you anyway!
Davy
Remrem,
I can't implement the macro you sent me.
Do you have any additional information to provide me please.
Thank you.
Hello
All the components of the assembly must be traversed, as shown in this macro:
Then fix them all as indicated in one of these two links:
Now, honestly, I'm overwhelmed.
I cannot reconcile the examples you offer with the case I am dealing with.
A colleague found a working macro however, it's locked and I don't have the password.
The main thing is that it works.
I share, in case others have the same needs.
Thank you all for your answers.
@+ on the forum.
Davy
Hello
- The 1st link allows you to list and work on all the parts of an assembly one by one (traverse assembly). This would be the first snippet of code to be implemented in a macro: it creates the loop. At first glance, only the first sub is to be used
- The 2nd link joins the @remrem link: it contains the commands to fix the component you're working on and the "fix the selected component" part to insert in the middle of the loop (at the debug.print level)
- The 3rd link should be a macro performing the previous operations but under SW2016: I can't find the FixGroup function under 2015
Thank you for this glaffont precision!
It's always good to take.
So you shouldn't have chosen my answer as the best! Since I didn't do much as a result.
I was tinkering with the code to make it work. But you answered before.
Thanks for putting the macro.
I will use it. :-)
I couldn't put my answer containing the macro as the solution.
So your answer is for me the closest.
You're welcome for the macro. Nevertheless, I would still be curious to be able to publish it.
As a good reward, here is the file without a password.
So it allowed me to see my mistake.
:-)
@remrem, thank you!
Is that your macro? Or you found the mdp...
It is important to know that the password of a macro is not a very effective protection.
You can cancel the protection with a simple hexadecimal reader.
Super! Thank you remrem!
However, it is impossible to download it.
Hello @davy,
There is a bug on Lynkoa that means that when you download the attachment of an answer, you have to re-enter the file extension instead of ".htm" as proposed in the dialog box. In your case, you need to write ".swp" for the last @remrem file.
Chances are, your download problem comes from this.
(also to be noted, but I think you know, that .swp files don't launch directly from an explorer, you have to go to Tools/Macro/Run)
I don't have any problems.
I use Firefox and W7.
Thank you for the information Benoit!