I am trying to create an assembly by inserting different drawings depending on the dimensions plugged into excel.
The Logic is solid in terms of when to add the different parts. My problem now is I don't know the code to insert the parts into the assembly.
I have tried the "record marco" and used that in the Excel VBA to no avail thus far.
an example of my efforts ( it continues on for quite a bit but this is the only bit of solidworks macro I have thus far):
Any help will be very much appreciated. I won't be able to re-test it till Monday .
Thanks
The Logic is solid in terms of when to add the different parts. My problem now is I don't know the code to insert the parts into the assembly.
I have tried the "record marco" and used that in the Excel VBA to no avail thus far.
an example of my efforts ( it continues on for quite a bit but this is the only bit of solidworks macro I have thus far):
Code:
Private Sub CommandButton1_Click()
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
Dim Bot_message As Integer
Dim myForm As doorMsgBox2
Set myForm = New doorMsgBox2
Dim Hinge As Hinge_Orientation2
Set Hinge = New Hinge_Orientation2
Dim Height As Integer
Dim Width As Integer
Dim Depth As Integer
Dim Curb As String
W = Range("C2").Value
H = Range("C3").Value
D = Range("C4").Value
If W > 120 Or W < 14 Then
Range("D1") = "Invalid Width"
ElseIf H > 71.5 Or H < 14 Then
Range("D1") = "Invalid Height"
ElseIf D > 32 Or D < 12 Then
Range("D1") = "Invalid Depth"
Else
Curb = blank
'*** Vertical hinge or Horizontal hinge
Hinge.Caption = "Hinge Orientation"
Hinge.Show
Select Case Hinge.Tag
Case 1
'***deciding if the cabinet has a bottom or not
Bot_message = MsgBox("Does the Cabinet have a bottom?", vbYesNoCancel, "Cabinet Bottom inquiry")
If Bot_message = 6 Then
If H > W And W + D + D + 8.185 <= 144 And H < 60 Then
' ***insert the solidworks code for bottom (i.e.insert bottom part)(big piece will be horizontal)
Part.AddComponent("Y:\N\sldwrks\macro\horizontal box\Horizontal_long.SLDPRT", 0, 0, 0)
ElseIf H > W Then
Any help will be very much appreciated. I won't be able to re-test it till Monday .
Thanks