Auto Insert all configurations Once
The macro posted in the thread above does almost exactly what I need, however the parts are not placed with their origins on the assembly origin. I am not sure how it decides to place the components and why they aren't all with their origins coincident.
Can anyone help me to modify this to place all the parts fixed with their origins on the assembly origin, with axes aligned?
Here is the Artem Taturevich macro from the above thread.
'------------------------------------------------------------------------------------
'Created by Artem Taturevych (Intercad, Australia)
'http://intercad.com.au/
'------------------------------------------------------------------------------------
'Disclaimer: The API examples are provided as is and should be used as reference only.
'You may redistribute it and/or modify it on the condition that this header is retained.
'In no event shall Intercad be liable for any types of damages whatsoever
'(including without limitation, damages from the loss of use, data, profits, or business)
'arising out of the uses of this information, applications, or services.
'------------------------------------------------------------------------------------Dim swApp As SldWorks.SldWorks
Dim swAssy As SldWorks.AssemblyDocSub main()
On Error Resume Next
Set swApp = Application.SldWorks
Set swAssy = swApp.ActiveDoc
If swAssy Is Nothing Then
MsgBox "Please open an assembly"
End
End If
Dim compPath As String
compPath = InputBox("Specify the path to the component")
Dim swDocType As Integer
Select Case LCase(Right(compPath, 6))
Case "sldprt"
swDocType = swDocumentTypes_e.swDocPART
Case "sldasm"
swDocType = swDocumentTypes_e.swDocASSEMBLY
Case Else
MsgBox "please specify the part or assembly document"
End
End Select
swApp.DocumentVisible False, swDocType
Dim swCompModel As SldWorks.ModelDoc2
Set swCompModel = swApp.OpenDoc6(compPath, swDocType, swOpenDocOptions_e.swOpenDocOptions_Silent, "", 0, 0)
swApp.DocumentVisible True, swDocTypeIf swCompModel Is Nothing Then
MsgBox "Failed to load specified document"
End
End If
Dim i As Integer
Dim vConfs As Variant
vConfs = swCompModel.GetConfigurationNames
For i = 0 To UBound(vConfs)
Dim swComp As SldWorks.Component2
Set swComp = swAssy.AddComponent5(compPath, swAddComponentConfigOptions_e.swAddComponentConfigOptions_CurrentSelectedConfig, "", True, vConfs(i), 0, 0, 0)
swComp.ReferencedConfiguration = vConfs(i)
Next
End Sub
Hello. Add:
After: Set swComp = swAssy....