
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The second sub (NormalTest) below creates the ClientGraphic and the first sub (NormalTest_MagnitdureChange) attempts to lengthen the associated LineSegment in the Y direction so you must select a face along the XZ plane so the before running the second sub so that the line segment runs only in the Y direction. That said, when I run the first sub its 2 MsgBox display the before and after coordinates which does display the ending points Y coordinate doubled but graphically there's no change. If you run the first sub again you'll get the same results meaning the double length did not take the first time this sub was run even though oLineSegment.EndPoint.Y has changed according to the after MsgBox from the previous executing of the first sub. Am I doing something wrong? If not then why
Public Sub NormalTest_MagnitudeChange() Dim oPartDocument As PartDocument Dim oFace As Face Dim oClientGraphics As ClientGraphics Dim oSurfaceEvaluator As SurfaceEvaluator Dim adPoint(2) As Double Dim adParams(1) As Double Dim adGuessParams() As Double Dim adMaxDeviations() As Double Dim aoSolutionNatureEnum() As SolutionNatureEnum Dim adNormals(2) As Double Dim oVector_Normal As Vector Dim oLineSegment As LineSegment Dim oPoint_Normal As Point Dim oGraphicsNode_CurveGraphics As GraphicsNode Dim oCurveGraphics As CurveGraphics Dim adStPt(2) As Double Dim adEndPt(2) As Double Set oPartDocument = ThisApplication.ActiveDocument On Error Resume Next Set oClientGraphics = oPartDocument.ComponentDefinition.ClientGraphicsCollection. _ Item("NormalTest") If Err.Number <> 0 Then MsgBox "You must run NormalTest first." Exit Sub End If On Error GoTo 0 Set oGraphicsNode_CurveGraphics = oClientGraphics.Item(1) Set oCurveGraphics = oGraphicsNode_CurveGraphics.Item(1) Set oLineSegment = oCurveGraphics.Curve MsgBox _ "Start pt: " & oLineSegment.StartPoint.X & ", " & oLineSegment.StartPoint.Y & _ ", " & oLineSegment.StartPoint.Z & vbCr & _ "End pt: " & oLineSegment.EndPoint.X & ", " & oLineSegment.EndPoint.Y & _ ", " & oLineSegment.EndPoint.Z oLineSegment.GetLineSegmentData adStPt, adEndPt adEndPt(1) = adEndPt(1) * 2 'Double the length in the Y direction oLineSegment.PutLineSegmentData adStPt, adEndPt ThisApplication.ActiveView.Update ' Update the view. MsgBox _ "Start pt: " & oLineSegment.StartPoint.X & ", " & oLineSegment.StartPoint.Y & _ ", " & oLineSegment.StartPoint.Z & vbCr & _ "End pt: " & oLineSegment.EndPoint.X & ", " & oLineSegment.EndPoint.Y & _ ", " & oLineSegment.EndPoint.Z End Sub
Public Sub NormalTest() Dim oPartDocument As PartDocument Dim oFace As Face Dim oClientGraphics As ClientGraphics Dim oSurfaceEvaluator As SurfaceEvaluator Dim adPoint(2) As Double Dim adParams(1) As Double Dim adGuessParams() As Double Dim adMaxDeviations() As Double Dim aoSolutionNatureEnum() As SolutionNatureEnum Dim adNormals(2) As Double Dim oVector_Normal As Vector Dim oLineSegment As LineSegment Dim oPoint_Normal As Point Dim oGraphicsNode As GraphicsNode Set oPartDocument = ThisApplication.ActiveDocument On Error Resume Next Set oFace = oPartDocument.SelectSet.Item(1) If Err Then MsgBox "A face must be selected." ' Delete any existing client graphics. oPartDocument.ComponentDefinition.ClientGraphicsCollection. _ Item("NormalTest").Delete Exit Sub End If Set oClientGraphics = oPartDocument.ComponentDefinition.ClientGraphicsCollection. _ Item("NormalTest") If Err.Number = 0 Then oClientGraphics.Delete ThisApplication.ActiveView.Update End If On Error GoTo 0 Set oClientGraphics = oPartDocument.ComponentDefinition. _ ClientGraphicsCollection.Add("NormalTest") Set oSurfaceEvaluator = oFace.Evaluator oFace.PointOnFace.GetPointData adPoint oSurfaceEvaluator.GetParamAtPoint adPoint, adGuessParams, adMaxDeviations, _ adParams, aoSolutionNatureEnum oSurfaceEvaluator.GetNormal adParams, adNormals Set oVector_Normal = ThisApplication.TransientGeometry.CreateVector( _ adNormals(0), adNormals(1), adNormals(2)) oVector_Normal.ScaleBy 2.54 'convert 1 cm to 1 inch Set oPoint_Normal = oFace.PointOnFace oPoint_Normal.TranslateBy oVector_Normal Set oLineSegment = ThisApplication.TransientGeometry.CreateLineSegment( _ oFace.PointOnFace, oPoint_Normal) Set oGraphicsNode = oClientGraphics.AddNode(1) oGraphicsNode.AddCurveGraphics oLineSegment ThisApplication.ActiveView.Update End Sub
Solved! Go to Solution.