I have VB6 Pro Edition, SolidWorks 2017 on Dell with Windows 7 64bite.
I’m looking for a Do Loop or SelectCase to iterate through the components in an assembly,
change the dimensions of each part (component) with an input box then force a rebuild
of the individual components and the assembly .
Code:
‘opens SolidWorks
Private Sub Command2_Click()
Set swApp = CreateObject("SldWorks.Application") 'SldWorks
- swApp.Visible = True
End Sub
‘opens assembly in SolidWorks
Private Sub Command4_Click()
Set part = swApp.OpenDoc6("F:\\SolidWorks 2017\\API\\BearingAssembly.SLDASM", 2, 0, "", longstatus, longwarnings)
- swApp.ActivateDoc2 "BearingAssembly", False, longstatus
Set part = swApp.ActiveDoc
Set swModel = swApp.ActiveDoc
End Sub
‘this code works to change the dimension of the active component
‘to the valve of a textbox
‘but I cannot iterate to the other parts (components)
‘in order to change their dimensions
Private Sub Command3_Click()
Set part = swApp.ActiveDoc
Set swModel = swApp.ActiveDoc
- part.Parameter("BallDiameter@Sketch1").SystemValue = txtDia * 0.0254
- part.Parameter("BallDiameter@Sketch1").SystemValue = swModel.ForceRebuild3(False)
End Sub
Code:/
The assembly has three components:
- a ballbearing: which has 1 dimension to change, the diameter of the bearing
- an innerring: has 2 dimensions to change, the recess diameter and the ring overall diameter
- an outerring: has 2 dimensions to change, the recess diameter and the ring overall diameter
I hoped to use something like this:
Code:
- part.Parameter("InnerRingRecessDiameter@Sketch1").SystemValue = txtDia * 0.0254
- part.Parameter("InnerRinglDiameter@Sketch2").SystemValue = txtDia2 * 0.0254
- part.Parameter(“InnerRinglDiameter@Sketch").SystemValue = swModel.ForceRebuild3(False)
I can redimension each component separately using several commandbuttons and textboxes
but I’m hoping to use an userform something like this, to input values into two textboxes to
rebuild the assembly and update the parts.
SolidworksEducator Student