sisau
Mechanical
- Mar 5, 2010
- 19
I am trying to edit a SW part using Microsoft Visual Basic. I just want to edit some dimensions. The code I am using is the following:
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
Set myDimension = Part.Parameter("dimension2@Sketch2")
myDimension.SystemValue = Excel.Range("C4") * 0.001
Set myDimension = Part.Parameter("dimension1@Sketch2")
myDimension.SystemValue = Excel.Range("C3") * 0.001
Set myDimension = Part.Parameter("dimension3@Sketch3")
myDimension.SystemValue = Excel.Range("C5") * 0.001
Part.ClearSelection2 True
boolstatus = Part.ForceRebuild3(True)
The problem I have is using "Set Part = swApp.ActiveDoc" because I can only edit an active part. This gives me 2 main problems:
- I can't edit a part that is not active/opened.
- If I open more than one part with the same name of the dimensions, all the parts are changed. (I know I could solve this just changing the names of the dimensions, but I don't want to).
What I would like to do is put some kind of reference to "set part" in order to change the part I want and not an active part.
I hope I have explained in a good way my problem... Thank you for your help!
Set swApp = CreateObject("SldWorks.Application")
Set Part = swApp.ActiveDoc
Set myDimension = Part.Parameter("dimension2@Sketch2")
myDimension.SystemValue = Excel.Range("C4") * 0.001
Set myDimension = Part.Parameter("dimension1@Sketch2")
myDimension.SystemValue = Excel.Range("C3") * 0.001
Set myDimension = Part.Parameter("dimension3@Sketch3")
myDimension.SystemValue = Excel.Range("C5") * 0.001
Part.ClearSelection2 True
boolstatus = Part.ForceRebuild3(True)
The problem I have is using "Set Part = swApp.ActiveDoc" because I can only edit an active part. This gives me 2 main problems:
- I can't edit a part that is not active/opened.
- If I open more than one part with the same name of the dimensions, all the parts are changed. (I know I could solve this just changing the names of the dimensions, but I don't want to).
What I would like to do is put some kind of reference to "set part" in order to change the part I want and not an active part.
I hope I have explained in a good way my problem... Thank you for your help!