Jump to content

Lisp Request: Point & Elevation at Vertices


doddkevin

Recommended Posts

Hi, I am looking for a LISP what will add a point and elevation at the vertices along a 3D polyline. (I am currently adding them as Cogo points but this is not ideal).

 

Best case scenario would be:

  • A lisp that adds a point and it's elevation when I click( snap) on a vertex or other feature.

The point and elevation would go on the currently active layer.

Has anyone come across something like this?   Thanks in advance.

Link to comment
Share on other sites

Something like this?

(defun c:pp( / )
  (setq txtHeight 11
	a8 (cons 8 (getvar "clayer")))
  (setq p (trans (getpoint "select point") 1 0))
  (entmake (list '(0 . "POINT") (cons 10 p) a8))
  (entmake (list '(0 . "TEXT") (cons 1 (rtos (last p))) (cons 10 p) a8 (cons 40 txtHeight)))
  )
  • Like 2
Link to comment
Share on other sites

Hi fuccaro, exactly like that. Thank you. 

 

I can see where to change the text height but is there a way to change the text style and number of decimal place displayed to 2 instead of 3? I'm sorry for asking but I have no idea how to write or edit these LSPs.

 

Thanks again.

Link to comment
Share on other sites

31 minutes ago, doddkevin said:

...is there a way to change the text style and number of decimal place displayed to 2 instead of 3?

 

Change the following line if you don't use call outs in rtos it pulls from your current units set.

(entmake (list '(0 . "TEXT") (cons 1 (rtos (last p) 2 2)) (cons 10 p) a8 (cons 40 txtHeight)))

 

Edited by mhupp
  • Like 1
Link to comment
Share on other sites

@doddkevin

Glad to read that it works for you!

To change the number of decimals, read HERE.-thanks to BIGAL for the detailed explanations :)

For the text style: see the last entmake in the code I posted for you. There is a list of "things" called "dotted pairs". The '(0 . "TEXT") is a dotted pair. (cons 40 txtHeight) will also result in a dotted pair. Well, to change the text style to "Standard", add to the list something like

'(7 . "Standard")

(see the apostrophe at the beginning!). Go ahead, play around and get familiar with Lisp expressions. Post again if still in trouble, we are here and for sure someone will help you!

Happy Lisping! :)

  • Like 1
Link to comment
Share on other sites

If its a 3dpline then just select pline and get its Co-ordinates, then can add all vertice points in one go. Ok step 2 is setting an angle for the text so it reflects sq off the pline. Another post request. 

 

(defun co-ords2xy (xyz co-ords / I XY )
(setq co-ordsxy '())
(if (= xyz 2)
  (progn
    (setq I 0)
    (repeat (/ (length co-ords) 2)
    (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords) ))
    (setq co-ordsxy (cons xy co-ordsxy))
    (setq I (+ I 2))
    )
  )
)
(if (= xyz 3)
  (progn
    (setq I 0)
    (repeat (/ (length co-ords) 3)
    (setq xy (list (nth i co-ords)(nth (+ I 1) co-ords)(nth (+ I 2) co-ords) ))
    (setq co-ordsxy (cons xy co-ordsxy))
    (setq I (+ I 3))
    )
  )
)
(princ)
)

(setq obj (vlax-ename->vla-object (car (entsel "\nPlease choose 2d or 3d pline "))))
(setq entname (vlax-get obj 'objectname))

(if (= entname "AcDb3dPolyline")
  (setq 23d 3)
  (setq 23d 2)
)

(setq coords (vlax-get obj 'coordinates))
(co-ords2xy 23d coords)
(setvar 'pdmode 34)
(foreach pt co-ordsxy
(command "point" pt)
)

 

Link to comment
Share on other sites

Thanks to everyone for the help. Off to a good start so far.

 

For context we are drafting a large topographic survey from a Laser Scan point cloud. We are manually drafting 3Dpolylines along road & kerb edges, bottom of walls etc. We then need to add points & elevations along the linework. I've attached an screenshot.

 

At the moment i'm using the LSP from @fuccaro. Which is creating a point and elevation to two decimal places when I click on a vertex. Still need to change the font style and alignment manually but it is much faster than what we were doing previously.

Untitled.png

Link to comment
Share on other sites

Yes point clouds were going to be the way of the future but when it comes to roadworks like kerbs it all falls apart, yes worked we had total stations and our own 3d drone, the drone was great in paddocks, but not really any good in a road as its grid based. Sometimes depending on the project a combination of the 2 methods a Field survey of strings and a point cloud may produce time savings. We have compared clouds to surveyed surfaces of roads and they are very close. 

Link to comment
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...