Twullf
Mechanical
- Jan 24, 2012
- 196
I have an automation which is working wonderfully except where it comes into putting the twist dimension into the sketches. The value being set is always in the correct place but the angle being measured is not consistent.
It is supposed to measure from the X-axis in the positive direction and the specified line in the negative y direction and set a specified value for this. However the angle being measured seems to randomly dimension it correctly and to dimension it in the positive x, positive y direction.
Here is the code:
Any help on this would be greatly appreciated.
It is supposed to measure from the X-axis in the positive direction and the specified line in the negative y direction and set a specified value for this. However the angle being measured seems to randomly dimension it correctly and to dimension it in the positive x, positive y direction.
Here is the code:
Code:
'------------------------------------------------------------------------------------------
' Dimension angle from linechord to x-axis as S*counter*_Twist
' Dimension is always going to the interior angle, not to the positive y and towards endpoint of chord
' ??Dimension constantly going to the +x, +y direction, to compensate Twist is
' 90+Tool-S*counter*_Twist 5-1-2012
'------------------------------------------------------------------------------------------
strTwist = "90+Tool-S" & counter & "_Twist"
dimObject1_3.Geometry = lineChord
dimObject1_3.AssocType = Sketch.AssocType.EndPoint
dimObject1_3.AssocValue = 0
dimObject1_3.HelpPoint.X = 0.0
dimObject1_3.HelpPoint.Y = 0.0
dimObject1_3.HelpPoint.Z = 0.0
dimObject1_3.View = workPart.ModelingViews.WorkView
datumAxis1 = CType( workPart.Datums.FindObject( "DATUM_CSYS(0) X axis" ), DatumAxis )
dimObject2_3.Geometry = datumAxis1
dimObject2_3.AssocType = Sketch.AssocType.EndPoint
dimObject2_3.AssocValue = 0
dimObject2_3.HelpPoint.X = 0
dimObject2_3.HelpPoint.Y = 0
dimObject2_3.HelpPoint.Z = 0
dimObject2_3.View = nullNXObject
dimOrigin3 = Transform.Apply( New Point3d( 10000 ,10000 ,0 ))
Try
sketchDimensionalConstraint3 = theSession.ActiveSketch.CreateDimension( Sketch.ConstraintType.MinorAngularDim, _
dimObject1_3, dimObject2_3, dimOrigin3, nullExpression, Sketch.DimensionOption.CreateAsDriving )
dimension3 = sketchDimensionalConstraint3.AssociatedDimension
expression3 = sketchDimensionalConstraint3.AssociatedExpression
expression3.RightHandSide = strTwist
Catch
MessageBox.Show( "Expression S" & counter & "_twist not set, sketch skipped", "Error", _
MessageBoxButtons.OK, MessageBoxIcon.Error )
booleanSketch = false
Exit Sub
End Try
Try
' Expression is still in use.
workPart.Expressions.Delete( expression3 )
Catch ex As NXException
ex.AssertErrorCode( 1050029 )
End Try
Any help on this would be greatly appreciated.