Line

Line

Anonymous
Not applicable
645 Views
11 Replies
Message 1 of 12

Line

Anonymous
Not applicable
how can i control a line
if the StartPoint and endPoint are parallel to X axis
0 Likes
646 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable
It's not quite clear what you're asking. Maybe a bit more explanation would help. Perhaps the Z values of your Start and End point are set to something other than 0. Just a wild guest at this point.

Joe
--
0 Likes
Message 3 of 12

Anonymous
Not applicable
Only what i need is checking for straight
line

 i  try like this

 If Entity.Angle <> 0
Then
    MsgBox "Line is NOT parallel to X axis... note
endpoint" 

    End If

But when Angel is 180 i have  the same

i like to do something like if angle 
<> 0 or <>180 then


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
It's
not quite clear what you're asking. Maybe a bit more explanation would help.
Perhaps the Z values of your Start and End point are set to something other
than 0. Just a wild guest at this point.

Joe
--

0 Likes
Message 4 of 12

Anonymous
Not applicable
if y coordinates are equal


style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">

Only what i need is checking for straight
line

 i  try like this

 If Entity.Angle <> 0
Then
    MsgBox "Line is NOT parallel to X axis... note
endpoint" 

    End If

But when Angel is 180 i have  the same

i like to do something like if angle 
<> 0 or <>180 then


style="BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
It's
not quite clear what you're asking. Maybe a bit more explanation would help.
Perhaps the Z values of your Start and End point are set to something other
than 0. Just a wild guest at this point.

Joe
--

0 Likes
Message 5 of 12

Anonymous
Not applicable
but how to do ??

if y coordinates are equal


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

if y coordinates are equal


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">

Only what i need is checking for straight
line

 i  try like this

 If Entity.Angle <> 0
Then
    MsgBox "Line is NOT parallel to X axis... note
endpoint" 

    End If

But when Angel is 180 i have  the same

i like to do something like if angle 
<> 0 or <>180 then


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
It's
not quite clear what you're asking. Maybe a bit more explanation would
help. Perhaps the Z values of your Start and End point are set to
something other than 0. Just a wild guest at this point.

Joe
--

0 Likes
Message 6 of 12

Anonymous
Not applicable
Here, I wrote you a little function that returns whether the line is parallel to the X axis.

Joe
--
Public Function ParallelToXAxis() As Boolean
Dim oEntity As AcadEntity
Dim Point As Variant
Dim oLine As AcadLine

On Error Resume Next
ThisDrawing.Utility.GetEntity oEntity, Point, "Select line "
If Err Then Exit Function

If TypeOf oEntity Is AcadLine Then
Set oLine = oEntity
If oLine.Angle = 0 Or oLine.Angle = 180 Then ParallelToXAxis = True
End If
End Function
0 Likes
Message 7 of 12

Anonymous
Not applicable
Warning! That last post is wrong. Unfortunately, the AutoCAD documentation is in error. The following, however,
works fine.

Joe
--
Public Function ParallelToXAxis() As Boolean
Dim oEntity As AcadEntity
Dim Point As Variant
Dim oLine As AcadLine

On Error Resume Next
ThisDrawing.Utility.GetEntity oEntity, Point, "Select line "
If Err Then Exit Function

If TypeOf oEntity Is AcadLine Then
Set oLine = oEntity
With ThisDrawing.Utility
If .AngleToString(oLine.Angle, acDegrees, 0) = 0 Or .AngleToString(oLine.Angle, acDegrees, 0) = 180 Then
ParallelToXAxis = True
End If
End With
End If
End Function
0 Likes
Message 8 of 12

Anonymous
Not applicable
thanks


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Warning!
That last post is wrong. Unfortunately, the AutoCAD documentation is in error.
The following, however,
works fine.

Joe
--
Public Function ParallelToXAxis() As Boolean
Dim oEntity
As AcadEntity
Dim Point As Variant
Dim oLine As AcadLine

On Error Resume Next
  ThisDrawing.Utility.GetEntity oEntity,
Point, "Select line "
  If Err Then Exit Function

If TypeOf oEntity Is AcadLine Then
    Set oLine =
oEntity
    With ThisDrawing.Utility

      If .AngleToString(oLine.Angle,
acDegrees, 0) = 0 Or .AngleToString(oLine.Angle, acDegrees, 0) = 180 Then

        ParallelToXAxis = True

      End If
    End
With
  End If
End Function

0 Likes
Message 9 of 12

Anonymous
Not applicable
Na, the code in your last post looks fine, you just forgot that the
angle property returns a value in radians, not degrees.

Just for giggles, using your original idea about the elements:

if oLine.startpoint(0) = oLine.endpoint(0) then ParallelToXAxis = True

-Josh 🙂


joesu wrote:

> Warning! That last post is wrong. Unfortunately, the AutoCAD
> documentation is in error. The following, however,
> works fine.
>
> Joe
0 Likes
Message 10 of 12

Anonymous
Not applicable
Which makes it wrong because it didn't have the AngleToString functions [which I would have had
had I not relied on the documentation].

Joe
--
0 Likes
Message 11 of 12

Anonymous
Not applicable
Hi Joe,
True, the docs do say dgrees and I see your point, I should have looked a
little closer at the change in your second post. I just glanced at it
and thought you went the anglefromXaxis route. Not criticizing or
anything, but to explore yet another route, how about:

If oLine.Angle = 0 Or oLine.Angle = PI Then ParallelToXAxis = True

Obviously, this is something you probably would want to limit to even
increments of degrees, but for even increments it's a breeze to convert
on the fly once you start looking at it as PI radians = 180 degrees and
2PI radians = 360 degrees,,,,
PI/12 = 15
PI/6 = 30
PI/2 = 90
PI = 180
3(PI/2) = 270 'or 3 X 90 = 270, ect.
2PI = 360
yatta, yatta, yatta

-Josh



joesu wrote:

> Which makes it wrong because it didn't have the AngleToString functions
> [which I would have had
> had I not relied on the documentation].
>
> Joe
> --
>
0 Likes
Message 12 of 12

Anonymous
Not applicable
That's an option. However, now I have to toat around the function to get Pi instead of using the AutoCAD built-in function of AngleToString. I guess it's a personal preference thing 'cause either way works.

Joe
--
0 Likes