TheSwamp

Code Red => VB(A) => Topic started by: jura on October 13, 2004, 03:04:30 AM

Title: Switch Start/Eindpoints for linetypes with text
Post by: jura on October 13, 2004, 03:04:30 AM
I'm using customer define linetypes. There is text in them and the text is upside down if the line is drawn from right to left. I started this simple routine to change all lines that were drawn the wrong way. But i get a type mismatch in the line "If Lijn.StartPoint < Lijn.EndPoint Then..."

What am I doing wrong?
Is there a way to check if a selection set (SS) already exists? Deleting a non-existing SS or Creating an existing SS generates an error.

Code: [Select]

Sub LineChange()
Dim Lijn As AcadLine
Dim templijn As AcadLine
Dim LijnenSSet As AcadSelectionSet

Set LijnenSSet = ThisDrawing.SelectionSets.Add("Line")
LijnenSSet.SelectOnScreen

For Each Lijn In LijnenSSet
    If Lijn.StartPoint < Lijn.EndPoint Then
    templijn.StartPoint = Lijn.StartPoint
    Lijn.StartPoint = Lijn.EndPoint
    Lijn.EndPoint = templijn.StartPoint
    End If
Next Lijn

LijnenSSet.Delete
End Sub
Title: Switch Start/Eindpoints for linetypes with text
Post by: Keith™ on October 13, 2004, 08:15:58 AM
The StartPoint and EndPoint of a line returns an array of the three coordinate values ... i.e. X,Y,Z So...since you are wanting to determine the left and right of the line, use the X (0th element of array) to compare...

Similar to
Code: [Select]

PT1 = Lijn.StartPoint
PT2 = Lijn.EndPoint
If PT1(0) > PT2(0) Then
 Lijn.StartPoint = PT2
 Lijn.EndPoint = PT1
End If


To delete an existing selection set that you know the name of, but do not have a reference object
Code: [Select]

ThisDrawing.SelectionSets.Item("Line").Delete
Title: Switch Start/Eindpoints for linetypes with text
Post by: jura on October 13, 2004, 08:51:07 AM
If only all things in life would be that simple.

Thx Keith.
Title: Switch Start/Eindpoints for linetypes with text
Post by: Keith™ on October 13, 2004, 12:02:25 PM
no problem.. glad to help
Title: Switch Start/Eindpoints for linetypes with text
Post by: pmvliet on October 13, 2004, 02:15:15 PM
I believe that text will also be backward from top to bottom or from bottom to top. To catch all instances you would have to compare the "Y" values as well because a vertical line will have the same "x" coordinate.

Pieter
Title: Switch Start/Eindpoints for linetypes with text
Post by: jura on October 19, 2004, 04:03:49 PM
Thx Pieter, (very dutch name btw)

I'm aware of that.

Didn't hurt in tellin' me though.