TomPeijs
Mechanical
- Oct 7, 2008
- 2
Hi,
I'm trying to drive variables through VBA in a Solid Edge Assembly, which holds two part-files. I want to be able to change the variables of both files. I have the following code to change the variables of 1 partfile, but it doesn't seem to be working: I don't even get errors!
Private Sub CommandButton3_Click()
On Error Resume Next
'Declare the program variables
Dim HipXRotation As Single
Dim ShoulderXRotation As Single
Dim SpineXRotation As Single
Dim objApp As Object
Dim objVariables As Object
Dim objDim As Object
Dim objDim2 As Object
Dim objDim3 As Object
Dim objDim4 As Object
Dim objDim5 As Object
Dim objDim6 As Object
'Connect to a running instance of Solid Edge
Set objApp = GetObject(, "SolidEdgeFramework.Application")
'Access the Variables collection.
Set objVariables = objApp.ActiveDocument.Occurrences.Item(2).PartDocument.Variables
Set objDim = objVariables.Translate("Left_Foot_X_Dist")
Set objDim2 = objVariables.Translate("Left_Foot_Y_Dist")
Set objDim3 = objVariables.Translate("Left_Foot_Z_Dist")
Set objDim4 = objVariables.Translate("Left_Hand_X_Dist")
Set objDim5 = objVariables.Translate("Left_Hand_Y_Dist")
Set objDim6 = objVariables.Translate("Left_Hand_Z_Dist")
'Start Simulation
For HipXRotation = -45 To 40 Step 17
Call objVariables.Edit("Left_Hip_X_Rotation", HipXRotation)
Call objVariables.Edit("Left_Ankle_Y_Rotation", -51.5)
Range("H15").Value = objDim.Value * 1000
Range("I15").Value = objDim2.Value * 1000
Range("J15").Value = objDim3.Value * 1000
Range("K15").Value = objDim4.Value * 1000
Range("L15").Value = objDim5.Value * 1000
Range("M15").Value = objDim6.Value * 1000
Next HipXRotation
For ShoulderXRotation = -110 To -90 Step 10
Call objVariables.Edit("Left_Shoulder_X_Rotation", ShoulderXRotation)
Range("H15").Value = objDim.Value * 1000
Range("I15").Value = objDim2.Value * 1000
Range("J15").Value = objDim3.Value * 1000
Range("K15").Value = objDim4.Value * 1000
Range("L15").Value = objDim5.Value * 1000
Range("M15").Value = objDim6.Value * 1000
Next ShoulderXRotation
For SpineXRotation = -40 To 40 Step 10
Call objVariables.Edit("Spine_X_Rotation", SpineXRotation)
Call objVariables.Edit("Left_Shoulder_X_Rotation", -90)
Range("H15").Value = objDim.Value * 1000
Range("I15").Value = objDim2.Value * 1000
Range("J15").Value = objDim3.Value * 1000
Range("K15").Value = objDim4.Value * 1000
Range("L15").Value = objDim5.Value * 1000
Range("M15").Value = objDim6.Value * 1000
Next SpineXRotation
For ShoulderXRotation = -90 To 98 Step 18.8
Call objVariables.Edit("Left_Shoulder_X_Rotation", ShoulderXRotation)
Range("H15").Value = objDim.Value * 1000
Range("I15").Value = objDim2.Value * 1000
Range("J15").Value = objDim3.Value * 1000
Range("K15").Value = objDim4.Value * 1000
Range("L15").Value = objDim5.Value * 1000
Range("M15").Value = objDim6.Value * 1000
Next ShoulderXRotation
End Sub
Does someone have an idea? Thanks in advance.
Regards,
Tom
I'm trying to drive variables through VBA in a Solid Edge Assembly, which holds two part-files. I want to be able to change the variables of both files. I have the following code to change the variables of 1 partfile, but it doesn't seem to be working: I don't even get errors!
Private Sub CommandButton3_Click()
On Error Resume Next
'Declare the program variables
Dim HipXRotation As Single
Dim ShoulderXRotation As Single
Dim SpineXRotation As Single
Dim objApp As Object
Dim objVariables As Object
Dim objDim As Object
Dim objDim2 As Object
Dim objDim3 As Object
Dim objDim4 As Object
Dim objDim5 As Object
Dim objDim6 As Object
'Connect to a running instance of Solid Edge
Set objApp = GetObject(, "SolidEdgeFramework.Application")
'Access the Variables collection.
Set objVariables = objApp.ActiveDocument.Occurrences.Item(2).PartDocument.Variables
Set objDim = objVariables.Translate("Left_Foot_X_Dist")
Set objDim2 = objVariables.Translate("Left_Foot_Y_Dist")
Set objDim3 = objVariables.Translate("Left_Foot_Z_Dist")
Set objDim4 = objVariables.Translate("Left_Hand_X_Dist")
Set objDim5 = objVariables.Translate("Left_Hand_Y_Dist")
Set objDim6 = objVariables.Translate("Left_Hand_Z_Dist")
'Start Simulation
For HipXRotation = -45 To 40 Step 17
Call objVariables.Edit("Left_Hip_X_Rotation", HipXRotation)
Call objVariables.Edit("Left_Ankle_Y_Rotation", -51.5)
Range("H15").Value = objDim.Value * 1000
Range("I15").Value = objDim2.Value * 1000
Range("J15").Value = objDim3.Value * 1000
Range("K15").Value = objDim4.Value * 1000
Range("L15").Value = objDim5.Value * 1000
Range("M15").Value = objDim6.Value * 1000
Next HipXRotation
For ShoulderXRotation = -110 To -90 Step 10
Call objVariables.Edit("Left_Shoulder_X_Rotation", ShoulderXRotation)
Range("H15").Value = objDim.Value * 1000
Range("I15").Value = objDim2.Value * 1000
Range("J15").Value = objDim3.Value * 1000
Range("K15").Value = objDim4.Value * 1000
Range("L15").Value = objDim5.Value * 1000
Range("M15").Value = objDim6.Value * 1000
Next ShoulderXRotation
For SpineXRotation = -40 To 40 Step 10
Call objVariables.Edit("Spine_X_Rotation", SpineXRotation)
Call objVariables.Edit("Left_Shoulder_X_Rotation", -90)
Range("H15").Value = objDim.Value * 1000
Range("I15").Value = objDim2.Value * 1000
Range("J15").Value = objDim3.Value * 1000
Range("K15").Value = objDim4.Value * 1000
Range("L15").Value = objDim5.Value * 1000
Range("M15").Value = objDim6.Value * 1000
Next SpineXRotation
For ShoulderXRotation = -90 To 98 Step 18.8
Call objVariables.Edit("Left_Shoulder_X_Rotation", ShoulderXRotation)
Range("H15").Value = objDim.Value * 1000
Range("I15").Value = objDim2.Value * 1000
Range("J15").Value = objDim3.Value * 1000
Range("K15").Value = objDim4.Value * 1000
Range("L15").Value = objDim5.Value * 1000
Range("M15").Value = objDim6.Value * 1000
Next ShoulderXRotation
End Sub
Does someone have an idea? Thanks in advance.
Regards,
Tom