The
DPLIP Function
This
function is long. And it is also a little bit complicated. But you
will understand the function. I hope.
Here
is the function:
(defun-dplip-(et-sp-ss-/-e1-el-ip-p1-p2-p3-p4)
---(setq-el-(entget-et)
---------p1-(cdr-(assoc-10-el))
---------p2-(cdr-(assoc-11-el))
---)
---(setq-e1-(ssname-ss-0))
---(if-(equal-et-e1)
------(setq-e1-(ssname-ss-1))
---)
---(setq-el-(entget-e1)
---------p3-(cdr-(assoc-10-el))
---------p4-(cdr-(assoc-11-el))
---)
---(if-(or-(=-(angle-p1-p2)(angle-p1-p3))
-----------(=-(angle-p1-p2)-(angle-p2-p3))
-------)
------(setq-ip-p3)
------(setq-ip-p4)
---)
---(if-(=-(+-(distance-p1-sp)
-------------(distance-sp-ip)
----------)
----------(distance-p1-ip)
-------)
------(command-"pline"-p1
-----------------------"w"
-----------------------2.5
-----------------------2.5
-----------------------ip
-----------------------""
------)
------(command-"pline"-p2
-----------------------"w"
-----------------------2.5
-----------------------2.5
-----------------------ip
-----------------------""
------)
---)---
)
We
give an entity to the function together with the selection point and
the selection set that was found in the previous function.
Finding
Two Points Of The Line
We
want to find the two points of the entity. The entity is a line. This
is how we find the two points of trhe line.
(setq-el-(entget-et)
p1-(cdr-(assoc-10-el))
p2-(cdr-(assoc-11-el))
)
Finding
The Other Line
Another
line is coming to the line that we have selected. We want to know
what that line is. It is in the selection set.
There
are two entities or two lines in the selection set. We take the first
entity of the selection set.
We
see if it is the same as the entity that was given to the function.
If it is, then we take the second entity of the selection set.
Here
are the programming lines:
(setq-e1-(ssname-ss-0))
(if-(equal-et-e1)
(setq-e1-(ssname-ss-1))
)
Now
we have the line that is drawn against the line that has been
selected. We find the points of that line. Here is how.
(setq-el-(entget-e1)
p3-(cdr-(assoc-10-el))
p4-(cdr-(assoc-11-el))
)
The
Point On The Selected Line
Now
we need to find what point is on the line that has been selected. We
check the angles. Here is how it is done.
(if
(or (= (angle p1 p2)(angle p1 p3))
(=
(angle p1 p2)(angle p2 p3))
)
(setq
ip p3)
(setq
ip p4)
)
Now
we know the two points of the line that has been selected. And we
know the point of the other line that is on the line.
How
The Polyline Is To Be Drawn
Now
we must figure out how a polyline is to be drawn. We must figure out
between what points the polyline must be drawn.
We
know. The polyline is drawn to the point of the other line that is on
the selected line. But from where is it drawn?
Is
it drawn from point P1 or is it drawn from point P2. The points P1
and P2 are from the selected line.
It
is quite simple to find out between what points the polyline must be
drawn. We look at the distances.
There
is the distance between P1 and the selection point and the distance
between the selection point and the point of the other line.
If
the total of those distances are the same as the distance between P1
and the point of the other line, then we know.
Then
the polyline is drawn from point P1 to the point of the other line.
Otehrwise it comes from point P2.
Here
are the lines of the AutoLISP program.
(if
(= (+ (distance p1 sp)
(distance sp ip)
)
(distance
p1 ip)
)
(command
"pline" p1
"w"
2.5
2.5
ip
""
)
(command
"pline" p2
"w"
2.5
2.5
ip
""
)
)
Next
Post
In
the next post I'm going to talk about the main part of the AutoLISP
program. And then I'm done talking about this AutoLISP program.
Something
Completely Different
Here is something
completely different from what you normally read in this blog. It is
an imagination.
Imagine this. One day you
wake up and you are a millionaire! Look at how different your life
will be:
- You
no longer have to worry about your debts, bills, and slaving for
money.
- You
can spend your time doing things you love, spend your time with your
beloved family and friends.
- You
no longer have to worry about money or have to be poor again. Never
again living the life you used to have.
Do you want to be a
millionaire? Make your dream lifestyle came true. Here's your chance
to be a millionaire. Check this out.
Wake Up Millionaire:
http://l1nk.com/rfbzla
To Your Success
Free
AutoLISP Course
Sorry. This offer is only
for my readers from Malaysia. I want to give an AutoLISP course to
them. Free of charge.
I have more than 900
readers. The majority of them is from the USA. More than 500. But I
also have readers from Malaysia. About 120.
I don't know what my
readers from Malaysia are doing. Are they with an engineering firm or
architecture? Or just interested in AutoLISP?
I offer them a free
AutoLISP course. It works like this. You let me know if interested
and I'll come to your place.
I will give the AutoLISP
course at your office. Your people can attend the AutoLISP course.
The course consist of 15 lessons.
The first ten lessons are
about AutoLISP. All the functions of AutoLISP are explained and there
is talked about the system variables.
During the last five
lessons we are going to write an AutoLISP program. The people
attending the course come with a wish.
That is why this offer is
only for my readers from Malaysia. I live in Malaysia. And I do not
see how I could travel abroad.
The AutoLISP course is
completely free. I will not charge you for the course. But I will ask
you to refund my travel expenses.
The people attending the
course will get an e-book about AutoLISP. The e-book is a PDF file.
What is said in the course, can be found in the book.
No comments:
Post a Comment