Jump to content

Recommended Posts

Sheep

Hi to all. This is my first post and i'm new at LISP. I need help to make a LISP for AC/DC lane base on user input.

1. User will enter nos of lane

2. Width of the lane.

3. Values for Lm, Tm, Ld,Td dan R.

User need to pick the center line (red) and the existing lane (green) to get the R (radius). As you can see, LM@Ld starts at the end of the R and at the end of Lm@Ld will start the tapper ( Tm@Td).

Again, im new at LISP and the only thing i can make won my own is this this. But the width is fixed and not based on user input. Thank you for your time and replies.

 

Quote

(Defun C:yy ( / p1 ob1)
  (command "offset" 3.65 (setq ob1 (entsel))  (setq p1 (getpoint)) "")
  (command "offset" 7.30 ob1 p1 "")
  (command "offset" 10.95 ob1 p1 "")
  (princ)
  );defun 

 

acdc.dwg

Share this post


Link to post
Share on other sites
BIGAL

For those here not civil engineers you want acceleration and deceleration lanes automated.

 

ok there are a few solutions where I come from the lanes have radius also rather than just a angle line.

 

Its  not to hard a question to answer. But there are some issues if the road is within a curve then it becomes way more complicated.

 

Before starting any code really need the Highway code for the task its no good doing something then changing it multiple times.

 

Most of the rules are speed dependant.

Edited by BIGAL

Share this post


Link to post
Share on other sites
Sheep
1 hour ago, BIGAL said:

Before starting any code really need the Highway code for the task its no good doing something then changing it multiple times.

 

Most of the rules are speed dependant.

Thank you for your reply. Actually Lm, Tm, Ld,Td dan R are from the Highway code and design. Yes, i do know curved alligment will become too much to code, that's why i leave it aside. Most of the AC/DC in the project are not curvy so a quick editing after it was automated can save plenty of time.

Edited by Sheep
typo

Share this post


Link to post
Share on other sites
BIGAL

Ok lets look at it for me its look at the steps for you write them down and then we convert to lisp.

 

I will get you started its a good learning example.

 

Pick white line offset left and right

pick red line offset say right will come back to left later

Offset white roadwidth + Rad + ld -td

Offset white roadwidth + Rad + ld

Fillet using rad offset lines 

draw taper line using intersecting points

trim up

ok now do left side  of Tee

Now do top side using same ideas.

 

As you make new lines you remember them (setq ent5 (entlast)) so you can do (command "fillet" "R" rad ent5 ent6)

 

Ok found 1st problem your dwg is not true 90 a real world case so even though I outlined above would now look at a different approach why not use points to make line work. Using the polar command you know the two critical lines and there angles 

 

Lastly thinking a bit more probably a combination of the two methods. I often throw away and do again realising a much better way to do.

 

Its about converting what you do manually 

 

image.thumb.png.36e817d5bdb47aff0760211bdfc7981a.png

Using polar command work out points 4-8 draw lines and fillet.

image.png.e6938cb3aaab040178c3e9a2b485cdcf.png

 

(setq pt1 (getpoint "Pick intersection point"))
(setq pt2 (getpoint "Pick end main road"))
(setq pt1 (getpoint "Pick end tee road"))
(setq ang1 (angle pt1 pt2))
(setq ang2 (angle pt1 pt3))
(setq off1 (getreal "enter full offset distance lane+widening"))
(setq off2 (getreal "enter Tee road lane width"))
.... enter rad td ld
use polar to work out pt4 pt5 pt6 pt7 pt8
line pt4 pt5 pt6
line pt7 pt8
fillet ent1 ent2

Last put a front end on it

image.png.592a20acdededb619883659004cb59b4.png

Edited by BIGAL

Share this post


Link to post
Share on other sites
Sheep
33 minutes ago, BIGAL said:

Ok lets look at it for me its look at the steps for you write them down and then we convert to lisp.

 

I will get you started its a good learning example.

 

Pick white line offset left and right

pick red line offset say right will come back to left later

Offset white roadwidth + Rad + ld -td

Offset white roadwidth + Rad + ld

Fillet using rad offset lines 

draw taper line using intersecting points

trim up

ok now do left side  of Tee

Now do top side using same ideas.

Thank you for your fast reply. Looking at your work here, you have helped many users and i'm glad you help me.

Going back to your reply on manual steps, i normally do this:

1. Offset the red line [2] accordingly to the width and nos of lane on both sides.

2. Fillet@Circle ( TTR ) to get the Rad.

3. Get the length of Lm@Ld

4. Construct the tapper [Tm@Td]

 

By using a dialogbox would be great idea. For a,b and c must be in their own layer and linetype and scale (refer to new picture). A.b and c must have min thickness (global width) of 0.3 and max 0.5. I'm sorry for not mentioning about layers and stuff.

 

Again,thank you for your time. 

I don't know if this will effect anything but i still use Autocad 2007 (yes, it's old) for all my dwg.

0.PNG

Share this post


Link to post
Share on other sites
BIGAL

2007 s not old, look up Autocad 1.4. The code will run in 2007. 

 

Have a go, I started the code for you, don't worry about layers/linetype etc get the shape to work 1st. I would use the point method as I have hinted.

Share this post


Link to post
Share on other sites
Sheep
22 hours ago, BIGAL said:

2007 s not old, look up Autocad 1.4. The code will run in 2007. 

 

Have a go, I started the code for you, don't worry about layers/linetype etc get the shape to work 1st. I would use the point method as I have hinted.

Thanks for the jump start. I'm new to LISP so i'll surely read plentty of LISP pdf. Again, thanks.

Share this post


Link to post
Share on other sites
BIGAL

Look into how polar works bear in mind the angles are in radians but unless you need to enter an angle don't worry about it for this task.

 

A bit of help

90 degs (/ pi 2.0)    (setq pt2 (polar pt1 (/ pi 2.0)  22)

180 Pi                        (setq pt2 (polar pt1 pi   22)

270 (* 1.5 pi)          (setq pt2 (polar pt1 (* 1.5 pi)   22)

(setq pt2 (polar pt1 (+  (/ pi 2.0) ang)   22) adds 90 to an angle.

 

The dialogue input is in the downloads section here at cadtutor but I would suggest start with (getreal "enter distance" etc

Edited by BIGAL

Share this post


Link to post
Share on other sites
Sheep

Quick question, can you point to me a good book/link so i can know what setq, polar,getpoint etc? is this correct?

Quote

(defun c:ACDC ( / pt1 pt2 pt3)
(setq pt1 (getpoint "Pick intersection point"))
(setq pt2 (getpoint "Pick end main road"))
(setq pt3 (getpoint "Pick end tee road"))
(command "line" pt1 pt2 pt3 "c")
(setq ang1 (angle pt1 pt2))
(setq ang2 (angle pt1 pt3))
)
(princ)
 

 

Share this post


Link to post
Share on other sites
BIGAL

Yes that code is correct so is

(setq off1 (getreal "enter full offset distance lane+widening"))
(setq off2 (getreal "enter Tee road lane width"))
(setq lanewid (getreal "Enter the main road width"))
(setq wide (getreal "Enter the widening width"))
(Setq  p4 (polar p1 ang1 dist1)) ; towards pt2
(setq p4 (polar p4 (- ang1 (/ pi 2.0)) (+ lanewid wide)) ; done twice as must be at 90 degs off line.
; can do a double polar (setq pt4 (polar (polar p1 ........
(setq pt5 ; your turn
(command "line pt4 pt5 "")

 

Share this post


Link to post
Share on other sites
Sheep
On 11/30/2019 at 1:40 PM, BIGAL said:

(Setq p4 (polar p1 ang1 dist1)) ; towards pt2

1. Where do i get dist1? I know pt1, p4 and ang1 is from the setq.

2. Below is the code i tried.

Quote

(defun c:ACDC ( / pt1 pt2 pt3)
(setq pt1 (getpoint "Pick intersection point"))
(setq pt2 (getpoint "Pick end main road"))
(setq pt3 (getpoint "Pick end tee road"))
;;(command "line" pt1 pt2 pt3 "c")
(setq ang1 (angle pt1 pt2))
(setq ang2 (angle pt1 pt3))
(setq off1 (getreal "enter full offset distance lane+widening"))
(setq off2 (getreal "enter Tee road lane width"))
(setq rad (getreal "enter turning radius"))
(setq td (getreal "enter Td value"))
(setq ld (getreal "enter Ld value"))
(setq lanewid (getreal "Enter the main road width"))
(setq wide (getreal "Enter the widening width"))
(Setq pt4 (polar pt1 ang1 dist1))
(setq pt4 (polar pt4 (- ang1 (/ pi 2.0)) (+ lanewid wide))
(setq pt4 (polar pt4 (- ang1 (/ pi 2.0)) (+ off1)) 
(setq pt5 (polar pt5 (- ang2 (/ pi 180.0)) (+ off2))
(command "Line" pt4 pt5 "")
)
(princ)
)
 

Can you please advise me how to fix this error "; error: bad argument type: numberp: nil"

Share this post


Link to post
Share on other sites
BIGAL

Look at my image and PT4 it is calculated from the distance  (+ ld off2 radius)

 

Your almost there for one side.

 

(setq wide (getreal "Enter the widening width"))
(setq dist1 (+ .............))
(Setq pt4 (polar pt1 ang1 dist1))
(setq pt4 (polar pt4 (- ang1 (/ pi 2.0)) (+ lanewid wide)))
(setq dist1 (- dist1 td))
(setq pt5 (polar pt1 ang1 dist1))
(setq pt5 (polar pt5 (- ang1 (/ pi 2.0)) (+ lanewid wide)))
(command "Line" pt4 pt5 "")
(setq dist1 (+ off2 rad))
(setq pt6 (polar pt1 ang1 dist1))
(setq pt6 (polar pt6 (- ang1 (/ pi 2.0)) off1))
(command "Line" pt6 pt5 "")
(setq l1 (entlast)) ; to be used later with fillet adn radius
(setq pt7 (polar pt1 ang2 .....))
(setq pt7 (polar pt7 ..............))

 

Edited by BIGAL

Share this post


Link to post
Share on other sites
Emmanuel Delay

[silly joke]

 

I thought you wanted the AC/DC logo.

In case you do ...

 


(vl-load-com)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Draw a polyline
;; https://www.cadtutor.net/forum/topic/18257-entmake-functions/
(defun LWPoly (lst cls)
 (entmakex (append (list (cons 0 "LWPOLYLINE")
                         (cons 100 "AcDbEntity")
                         (cons 100 "AcDbPolyline")
                         (cons 90 (length lst))
                         (cons 70 cls))
                   (mapcar (function (lambda (p) (cons 10 p))) lst)))
)

(defun c:acdc ( / data a)
  (setq data
    (list
      '((1.6905 1.55027) (2.20405 1.06033) (2.71946 1.57109) (2.48811 1.76213)
        (2.48811 3.65217) (1.71779 4.35778) (0.892307 3.60286) (0.892307 1.76634)
        (0.65594 1.55624) (1.18045 1.06951))

      '((1.4799 2.73277) (1.89083 2.73277) (1.89083 3.32695) (1.4799 3.69405))
      
      '((1.4827 2.13485) (1.4827 1.77067) (1.68758 1.57361) (1.88384 1.77067) (1.88384 2.13485))

      '((3.44967 4.37445) (2.67667 3.65673) (2.67667 1.74523) (3.41504 1.06647) (4.23912 1.84753)
      (3.80836 2.23932) (3.36478 1.84771) (3.26951 1.9403) (3.26951 3.662) (3.81711 3.17849) (4.26314 3.60959))

      '((5.55062 3.69932) (4.89598 3.69932) (4.22559 2.2953) (4.72281 2.2953)
      (4.18629 0.848992) (5.73522 2.85274) (5.21933 2.85274))

       '((6.90364 4.3586) (6.15746 4.3586) (5.71691 3.92475) (5.94174 3.69645) (5.94174 1.73324) (5.70478 1.51149)
      (6.15198 1.0777) (6.91297 1.0777) (7.54768 1.67106) (7.54768 3.75138))

      '((6.53504 3.78957) (6.53504 1.61555) (6.95157 1.99675) (6.95157 3.40942))

       '((8.49933 4.37445) (7.72632 3.65673) (7.72632 1.74523) (8.42643 1.0302)
      (9.28877 1.84753) (8.85802 2.23932) (8.41443 1.84771) (8.31916 1.9403) (8.31916 3.662) (8.86676 3.17849) (9.31279 3.60959))
    )
  )
  (foreach a data
    (LWPoly a 1)
  )
)

 

[/silly joke]

Share this post


Link to post
Share on other sites
Sheep
15 hours ago, Emmanuel Delay said:

[silly joke]

 

I thought you wanted the AC/DC logo.

In case you do ...

[/silly joke]

Nice one but now you made me even confused haha. But yeah, a new learning stuff for me, thanks.

  • Like 1

Share this post


Link to post
Share on other sites
Sheep
On 12/3/2019 at 8:54 AM, BIGAL said:

Look at my image and PT4 it is calculated from the distance  (+ ld off2 radius)

Your almost there for one side.

 

 

Thanks for the reply. A bit busy with making 40+ acdc lane manually. Will take a look at your comment later. Thanks.

Share this post


Link to post
Share on other sites
Sheep

I now can understand about polar getpoint angel and getreal little bit. But, how to i make the radius at the last lane? the length of the "Lm" & "Ld" starts at the end of radius.

Share this post


Link to post
Share on other sites
BIGAL

You could make the radius but its much easier to use the fillet command and let autocad do the work.

When you draw the line pt5-pt6 you do this (setq ent1 (entlast)) this remembers the new line entity.

Then draw line pt7-pt8 and again (setq ent2 (entlast))

Easy now (command "fillet" "R" rad ent1 ent2) and radius is drawn.

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...