AnsweredAssumed Answered

Assembly from part/assemby

Question asked by Patrice Marlier on Mar 17, 2018
Latest reply on Mar 27, 2018 by Murali B,B.

Hi all,

 

I am a beginner in the API

I would like to create an assembly from part of which I know the way.

I tried to use the macro recorder to look at the code but it does not work.

Do you have a basis code for this type of macro

 

It would be great if you can help me

 

Thank you

Dim swApp As Object

 

Dim Part As Object

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

 

Sub main()

 

Set swApp = Application.SldWorks

 

Set Part = swApp.OpenDoc6("C:\Plans\ASM1.SLDASM", 2, 0, "", longstatus, longwarnings)

  1. swApp.ActivateDoc2 "ASM11", False, longstatus

Set Part = swApp.ActiveDoc

'Set Part = swApp.ActiveDoc

Dim myModelView As Object

Set myModelView = Part.ActiveView

  1. myModelView.FrameLeft = 0
  2. myModelView.FrameTop = 0

Set myModelView = Part.ActiveView

  1. myModelView.FrameState = swWindowState_e.swWindowMaximized

Set myModelView = Part.ActiveView

  1. myModelView.FrameState = swWindowState_e.swWindowMaximized

boolstatus = Part.AddComponent("C:\Plans\PART1.SLDASM", 0, 0, 0)

boolstatus = Part.AddComponent("C:\Plans\PART2.SLDASM", 100, 100, 100)

End Sub

Outcomes