krywarick6
Automotive
- Jun 9, 2003
- 138
My programming experience in minimal, but I’m writing a macro in Excel. I’m learning as I go.
The macro calls a model and changes designated values. The value that the feature belongs to is irrelevant.
Upon calling the model, I’m trying to activate a given/named configuration, change a value, rebuild, activate the next given/named configuration and change another value and rebuild.
I’m getting stuck on ShowConfiguration2 (“config name”). I think this is the command that I’m looking for, but how to get it to work is my problem.
Here’s a generic copy of what I’ve written in Excel.
All of the Part.Parameter stuff works fine otherwise.
I get stuck at the ‘Activate Config1 part. What do I put in this section?
Any help would be greatful. Simple too, for the learner, please.
Sub Macro()
Dim swApp As Object
Dim Part As Object
Set swApp = CreateObject("SldWorks.Application")
swApp.Visible = True
Set Part = swApp.ActiveDoc
' Load model and expand window
Set Part = swApp.OpenDoc("path\part.SLDPRT", 1)
Set Part = swApp.ActivateDoc("part.SLDPRT")
swApp.ActiveDoc.ActiveView.FrameLeft = 0
swApp.ActiveDoc.ActiveView.FrameTop = 0
swApp.ActiveDoc.ActiveView.FrameState = 1
swApp.ActiveDoc.ActiveView.FrameState = 1
'Activate Config1
' Set values for Config 1 and rebuild model
Part.Parameter("D1@Helix1@part.SLDPRT").SystemValue = Range("C12").Value / 1000
Part.EditRebuild
'Activate Config2
' Set values for Config 1 and rebuild model
Part.Parameter("D1@Helix1@part.SLDPRT").SystemValue = Range("C12").Value / 1000
Part.EditRebuild
End Sub
Regards,
Christopher Zona
Litens Automotive Partnership
Concord, Ontario, Canada
The macro calls a model and changes designated values. The value that the feature belongs to is irrelevant.
Upon calling the model, I’m trying to activate a given/named configuration, change a value, rebuild, activate the next given/named configuration and change another value and rebuild.
I’m getting stuck on ShowConfiguration2 (“config name”). I think this is the command that I’m looking for, but how to get it to work is my problem.
Here’s a generic copy of what I’ve written in Excel.
All of the Part.Parameter stuff works fine otherwise.
I get stuck at the ‘Activate Config1 part. What do I put in this section?
Any help would be greatful. Simple too, for the learner, please.
Sub Macro()
Dim swApp As Object
Dim Part As Object
Set swApp = CreateObject("SldWorks.Application")
swApp.Visible = True
Set Part = swApp.ActiveDoc
' Load model and expand window
Set Part = swApp.OpenDoc("path\part.SLDPRT", 1)
Set Part = swApp.ActivateDoc("part.SLDPRT")
swApp.ActiveDoc.ActiveView.FrameLeft = 0
swApp.ActiveDoc.ActiveView.FrameTop = 0
swApp.ActiveDoc.ActiveView.FrameState = 1
swApp.ActiveDoc.ActiveView.FrameState = 1
'Activate Config1
' Set values for Config 1 and rebuild model
Part.Parameter("D1@Helix1@part.SLDPRT").SystemValue = Range("C12").Value / 1000
Part.EditRebuild
'Activate Config2
' Set values for Config 1 and rebuild model
Part.Parameter("D1@Helix1@part.SLDPRT").SystemValue = Range("C12").Value / 1000
Part.EditRebuild
End Sub
Regards,
Christopher Zona
Litens Automotive Partnership
Concord, Ontario, Canada