Jump to content

Lisp for drawing line and add text on cross section


Recommended Posts

romparkin

Hello, I need some help with drawing lines , I try to explain what i need.

I have a lot of cross sections to create, and the dwg files provided to me  as 2d not 3d, so I have no elevation data. l'm using Progecad 2021, and it has AutoSEZ addon built it, the module is creating the cross sections, but I need to edit them individually and edit add missing elements.

In attached file you see , I have 3 areas to fill , the 2 ditches on sides, and the main road profile in center.

Now I'm following this steps:

- Make a (red) centerline for each ditch , then copy paste a group made of a polyline and text, that snaps to the bottom vertex of centerline , then adjust the polyline to snap to edges of ditch, and delete the centerline

- And the next step is to copy a group made of a polyline and text and snap to the center line to get then road profile, then extend or trim the line to the edges of the road

 

Now, sometimes id a ditch on both sides, sometime just one side, sometimes no ditch just the road profile.

 

I have very little experience writing Lips, I did edited some free ones to fit my needs, and I wonder if there is possible to make 1 lisp to automate this steps I make, or 2 lisp files: one for center profile one for the ditch part ?

 

Need to mention must be simple Lisp not Visual lisp , as Progecad wont be able to run it.

 

If someone can guide me how to create a Lisp that make a line or polyline , by  selecting the 2 top vertex of ditch side , then calculate where is the centerline, and draw at a degree (set in lisp, with overwrite possibility ) from 1st  to centerline then back on same degree to second vertex , and add a text.

And for second lisp , I guess the steps would be, pick the road center top vertex , pick the road sides (lines) , and at a certain degree (set in lisp but possible overwrite it on command) draw 2 lines on left and right + add text above.

 

Let me know if is possible and if it is some hints, would be great

 

Thanks a lot

Romeo

 

cad-profile-lisp.thumb.png.e6ceb1e7b28e3f4ace8f76d2870422d9.png

Link to post
Share on other sites
BIGAL

The drains are very easy to draw, you get 2 points, then work out a 3rd point and draw 2 lines. (command "LINE" pt1 pt3 pt2 "")

 

(setq pt1 (getpoint "\nPick point 1 ")) 
(setq pt2 (getpoint "\nPick point 2 "))

(setq x1 (car pt1) y1 (cadr pt1))
(setq x2 (car pt2) y2 (cadr pt2))

(setq X (/ (+ x1 x2) 2.0)))
(setq Y (- y depth))
(seqt pt3 (list X Y))

 

You can apply the same type of idea to the centre line.

Link to post
Share on other sites
romparkin

Hi BIGAL, and thanks for the quick reply.

It was very helpful, gave me the direction to move on, and I made this solution, I know there are room for improvements.

 

Here is what I did:

 

defun C:SNT ( / pt1 pt2 pt3 midist distlung) ; Im not sure if all this "variables" need to be passes as arguments

(setq pt1 (getpoint "\nSelect first point: "))
(setq pt2 (getpoint "\nSelect second point: "))
(setq midist (/ (distance pt1 pt2) 2.0)) ; calculates half of distance
(setq distlung (/ (* midist 2.0) 1.7320508075688772)) ; calculates corect lenght for 30 degree 


(setq pt3 (polar pt1 5.7595865316 distlung)) ; angle as radians

(command "Line" pt1 pt3 pt2 "")

)

 

The  above LISP draws exactly what I need, and saves me some extra clicks for each cross section.

I also want to Insert some text just after lines are created, but adding a second Command for the text , like (command "Text" "x,y" 0.25 0 "Sant") is not working.

I would like to place it just where the middle point is,  like in example attached.

 

cad-profile-lisp.png.fb1cd6cb5b6d2989e2967cc6c6e9e2f5.png

 

I would like the text to be set in Lisp,  like rotation, size, etc,  so the software is not asking anything , just place it.

Any suggestion how to achieve this?

 

Thanks

Gal Romeo

Link to post
Share on other sites
Isaac26a
8 hours ago, romparkin said:

The  above LISP draws exactly what I need, and saves me some extra clicks for each cross section.

I also want to Insert some text just after lines are created, but adding a second Command for the text , like (command "Text" "x,y" 0.25 0 "Sant") is not working.

I would like to place it just where the middle point is,  like in example attached.

Why don't you try:

(setq pt4 (list (/ (+ (car pt1) (car pt2)) 2) (/ (+ (cadr pt1) (cadr pt2)) 2)))
(command "text" "_s" "standard" pt4 "0.25" "90" "Sant")

 

Edited by Isaac26a
Link to post
Share on other sites
mhupp

One problem that you have to keep in mind. pt1 has to be left of pt2. updated the wording of Select point so you dont select backwards.

Made a check so things are drawn the same no matter the order of points picked.

if your always going to pick left to right just remove the if statments and the 2nd option for pt3 and pt4

 

(defun C:SNT (/ pt1 pt2 pt3 pt4 midist distlung)         ; its always good to list our variables
  (defun DtR (d) (* pi (/ d 180.0)))                     ; converts Degrees to Radians
  (setq pt1 (getpoint "\nSelect Point 1:"))
  (setq pt2 (getpoint "\nSelect Point 2:"))
  (setq midist (/ (distance pt1 pt2) 2.0))               ; calculates half of distance
  (setq distlung (/ (* midist 2.0) 1.7320508075688772))  ; calculates corect lenght for 30 degree
  (if (< (car pt1) (car pt2))
    (setq pt3 (polar pt1 (DtR 330) distlung))              ; uses DtR to convert to radians
    (setq pt3 (polar pt1 (DtR 210) distlung))              ; uses DtR to convert to radians
  )
  (command "_.Pline" pt1 pt3 pt2 "")					           ; make one pline instead of two lines
  (if (< (car pt1) (car pt2))
    (setq pt4 (polar pt1 0 midist))   					           ; easier point caclulation.                    
    (setq pt4 (polar pt2 0 midist))
  )
  (command "_.Text" "_S" "Standard" "_J" "ML" pt4 "0.25" "90" "Sant")  ;added middle left justify
)

 

 

Edited by mhupp
removed visual lisp commands
Link to post
Share on other sites
Isaac26a
On 10/19/2021 at 2:26 AM, romparkin said:

Need to mention must be simple Lisp not Visual lisp , as Progecad wont be able to run it.

I think Mhupp made a good solution, you just have to change vl-cmdf for command, since it's only plain lisp.

  • Thanks 1
Link to post
Share on other sites
BIGAL

You want 2 drains or more ? See while.

 

(defun C:SNT (/ pt1 pt2 pt3 pt4 midist distlung)         ; its always good to list our variables
  (defun DtR (d) (* pi (/ d 180.0)))                     ; converts Degrees to Radians
  (while (setq pt1 (getpoint "\nSelect Point 1: press Enter to leave"))
  (setq pt2 (getpoint "\nSelect Point 2:"))
  (setq midist (/ (distance pt1 pt2) 2.0))               ; calculates half of distance
  (setq distlung (/ (* midist 2.0) 1.7320508075688772))  ; calculates corect lenght for 30 degree
  (if (< (car pt1) (car pt2))
    (setq pt3 (polar pt1 (DtR 330) distlung))              ; uses DtR to convert to radians
    (setq pt3 (polar pt1 (DtR 210) distlung))              ; uses DtR to convert to radians
  )
  (command "_.Pline" pt1 pt3 pt2 "")					           ; make one pline instead of two lines
  (if (< (car pt1) (car pt2))
    (setq pt4 (polar pt1 0 midist))   					           ; easier point caclulation.                    
    (setq pt4 (polar pt2 0 midist))
  )
  (command "_.Text" "_S" "Standard" "_J" "ML" pt4 "0.25" "90" "Sant")  ;added middle left justify
) ; while
)

 

Link to post
Share on other sites
romparkin

Big thanks to Isaac26a mhupp  and BIGAL 

 

Now my workflow improved a lot, and I have the base to create more Lisp for other elements I want to speedup in CAD work.

One more question, If I want to add another command in same Lisp file, for example once I finished the ditches I wan to run a draw road axis function, (something similar, pick center point, left ,right,...) I can add a different function in same Lisp, or should I create another lisp for that ?

 

 

Link to post
Share on other sites
zwonko

Typu can have multiple function in one *.lsp file or separate function in two *.lsp files. Your one lisp function (your SNT for example) can do as much as You want. For example You can do ditches and axis on one lisp function (SNT do ditches and axis). Or in two function one for ditches one for axis (SNT and for example AX). Is just as You want and as You need

Edited by zwonko
Link to post
Share on other sites
romparkin
15 minutes ago, zwonko said:

Typu can have multiple function in one *.lsp file or separate function in two *.lsp files. Your one lisp function (your SNT for example) can do as much as You want. For example You can do ditches and axis on one lisp function (SNT do ditches and axis). Or in two function one for ditches one for axis (SNT and for example AX). Is just as You want and as You need

 

Thanks zwonko, just working on adding a second function and command on same lisp file, and test how it works

 

found this topic : 

 

 

Thanks a lot for support 

Romeo

Edited by romparkin
Link to post
Share on other sites
romparkin
1 minute ago, diskoalnis said:

Hi romparkin.

What software are you using to make the cross section?

 

Hi , I have  a license of Progecad 2021 , an it has an addon called Autosez , see here:
https://www.progesoft.com/products/progecad-professional/manual?mp=progecad-features/add-on-advanced-functions/autosez

 

As I understand,  the developer of this addon, made it as a lisp originally, but the addon on Progecad was made specially for this Intellicad version.

 

The original lisp can found on this forum (italian language, but use google to translate it ) 

https://www.cad3d.it/forum1/threads/autosez-2-sezioni-e-profili-del-terreno-estrazione-automatica.17601/page-10

 

I hope that helps

Romeo

 

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.   Restore formatting

  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...