Moving EndPoint/StartPoint of Centerline On Drawing

Moving EndPoint/StartPoint of Centerline On Drawing

Tiffany_Hayden_
Collaborator Collaborator
624 Views
2 Replies
Message 1 of 3

Moving EndPoint/StartPoint of Centerline On Drawing

Tiffany_Hayden_
Collaborator
Collaborator

I've searched on the forums and I found back in 2005 that it wasn't possible to move the end points/start points. I'm curious if anything has changed. I know it's possible to move it manually. 

 

Below I'm trying to move the start/end point of a centerline on a drawing. If anyone has any tips I'd appreciate it. 

 

Public Sub MoveCenterlinePoints()

    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet

    Dim oCenterline As Centerline
    Dim oWFeatureName As String
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry
    Dim oPt2D As Point2d
    Dim oCenterLinePt2D As Point2d
    Dim strPointPos As String
    

    For Each oCenterline In oSheet.Centerlines
        oWFeatureName = oCenterline.ModelWorkFeature.Name
            If oWFeatureName <> "XY Plane" And oWFeatureName <> "YZ Plane" And oWFeatureName <> "XZ Plane" Then
                If oCenterline.StartPoint.X / 2.54 = oCenterline.EndPoint.X / 2.54 Then
                    If oCenterline.StartPoint.Y / 2.54 > oCenterline.EndPoint.Y / 2.54 Then
                        strPointPos = "START"
                    Else
                        strPointPos = "END"
                    End If
                Else
                    If oCenterline.StartPoint.X / 2.54 < oCenterline.EndPoint.X / 2.54 Then
                        strPointPos = "START"
                    Else
                        strPointPos = "END"
                    End If
                End If
            End If
        
        
        If strPointPos = "START" Then
            Set oCenterLinePt2D = oCenterline.StartPoint
            Set oCenterLinePt2D = oTG.CreatePoint2d(100, 100)
        Else
            Set oCenterLinePt2D = oCenterline.EndPoint
            Set oCenterLinePt2D = oTG.CreatePoint2d(100, 100)
        End If
        
        
    Next
    
End Sub

 

Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes
Accepted solutions (1)
625 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

I am not sure if I understand correctly, buy You can try this code.

I added line for empty ModelWorkFeature (which may cause an error).

I aslso added reseting strPointPos property after changing centerline - it kept oldvalue.

But this code will change either startpoint or endpoint whit the same value, so I don't understand the point.

Public Sub MoveCenterlinePoints()

    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet

    Dim oCenterline As Centerline
    Dim oWFeatureName As String
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry
    Dim oPt2D As Point2d
    Dim oCenterLinePt2D As Point2d
    Dim strPointPos As String
    

    For Each oCenterline In oSheet.Centerlines
        If oCenterline.ModelWorkFeature Is Nothing Then
        oWFeatureName = ""
        Else
        oWFeatureName = oCenterline.ModelWorkFeature.Name
        End If
        
            If oWFeatureName <> "XY Plane" And oWFeatureName <> "YZ Plane" And oWFeatureName <> "XZ Plane" Then
                If oCenterline.StartPoint.X / 2.54 = oCenterline.EndPoint.X / 2.54 Then
                    If oCenterline.StartPoint.Y / 2.54 > oCenterline.EndPoint.Y / 2.54 Then
                        strPointPos = "START"
                    Else
                        strPointPos = "END"
                    End If
                Else
                    If oCenterline.StartPoint.X / 2.54 < oCenterline.EndPoint.X / 2.54 Then
                        strPointPos = "START"
                    Else
                        strPointPos = "END"
                    End If
                End If
            End If
        
        
        If strPointPos = "START" Then
            'Set oCenterLinePt2D = oCenterline.StartPoint
            Set oCenterLinePt2D = oTG.CreatePoint2d(100, 100)
            oCenterline.StartPoint = oCenterLinePt2D
        Else
            'Set oCenterLinePt2D = oCenterline.EndPoint
            Set oCenterLinePt2D = oTG.CreatePoint2d(100, 100)
            oCenterline.EndPoint = oCenterLinePt2D
        End If
        
        strPointPos = ""
    Next
    
End Sub

 

0 Likes
Message 3 of 3

Tiffany_Hayden_
Collaborator
Collaborator

Thank you @Anonymous. The point for me was to move the centerlines outside the margins of the view. Your code for 

            Set oCenterLinePt2D = oTG.CreatePoint2d(100, 100)
            oCenterline.EndPoint = oCenterLinePt2D

was the adjustment I needed. I wasn't pushing the new point into the end point. That was the trick! Thanks for your help!

Tiffany Hayden
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature

0 Likes