DDS-NCorette Posted November 18, 2021 Posted November 18, 2021 Hello all, I am looking for a lisp file that would take a list of values (representing distances), either from an excel file or text document, and place points along a specified polyline at those distances. We have both cumulative distances, and non-cumulative, so either one could be used. Almost like a path array of points along a polyline, but instead of regular intervals for the points, the points would be placed at the distances specified in the excel file. If anyone has any ideas, that would be greatly appreciated. Thanks, Noah Quote
mhupp Posted November 18, 2021 Posted November 18, 2021 To Get you started just read values out of the file then use the following. Quote
BIGAL Posted November 19, 2021 Posted November 19, 2021 There are many examples of Chainage.lsp that write a chainage along a pline I would start there look at the method in the code. Quote
DDS-NCorette Posted November 19, 2021 Author Posted November 19, 2021 Thanks for the help guys, I think I'm getting close on this... I found a lisp (READVTXDIST, courtesy of hosneyalaa) that reads a .txt file list of numbers and adds a vertex to a specified polyline at each of those distances along the polyline. I also found a lisp (PTS, courtesy of marko_ribar) that will place a point at every vertex of a specified polyline. The only issue left is that I don't need the points at the vertices that were already on the polyline before running READVTXDIST... I tried to modify the READVTXDIST lisp to add a point at the distances from the txt file instead of adding a vertex to the polyline, but due to my extremely limited lisp coding abilities, I was unsuccessful... Perhaps that would be an easy change for someone more versed in lisp language, or perhaps there is an easy way to omit those points that I am overlooking. READVTXDIST.lsp PTS.lsp Quote
BIGAL Posted November 20, 2021 Posted November 20, 2021 I dont understand just use (setq pt (vlax-curve-getPointAtDist plineo (atof ln))) (command "point" pt) Quote
DDS-NCorette Posted November 22, 2021 Author Posted November 22, 2021 Hey BIGAL, Perfect. I threw that in the READVTX lisp code, and it worked exactly as I needed. Like I said I have very limited knowledge of lisp coding, I learned VB and Java in hichschool, so I have a basic understanding of the principles of programming, I just don't really know any lisp syntax. Unfortunately I don't have much time to dedicate to learning it, so help from folks like yourself is greatly appreciated! I attached the final version of the lisp that I will be using to save me tons of time. Thanks again for the help! READVTXDIST.lsp 1 Quote
BIGAL Posted November 23, 2021 Posted November 23, 2021 Use VBA its in Autocad Bricscad, Microstation to mention a few. Note may need to download the VBA extension module for your version of Autocad. 1 Quote
Ish Posted November 23, 2021 Posted November 23, 2021 (edited) 18 hours ago, DDS-NCorette said: Hey BIGAL, Perfect. I threw that in the READVTX lisp code, and it worked exactly as I needed. Like I said I have very limited knowledge of lisp coding, I learned VB and Java in hichschool, so I have a basic understanding of the principles of programming, I just don't really know any lisp syntax. Unfortunately I don't have much time to dedicate to learning it, so help from folks like yourself is greatly appreciated! I attached the final version of the lisp that I will be using to save me tons of time. Thanks again for the help! READVTXDIST.lsp 2.11 kB · 3 downloads Sir, any possibility in this lisp to add code for label marking or chainage marking along with point also. Example start chainage of pline is Ch 025+100.00 and distance in txt file 25, 35, 85 etc So output is Ch 025+025.00, Ch 025+035.000 like that on pline. Thanks Edited November 23, 2021 by Ish Modified Quote
aridzv Posted January 29, 2022 Posted January 29, 2022 (edited) @DDS-NCorette Hi. I've tried to run the lisp but I'm getting all the points at the polyline start...(see attached screenshot and the TXT input file I'm using) can you upload a sample of a TXT input file? I suspect that the TXT format I'm using is wrong. thanks, Ari. testline.txt Edited January 29, 2022 by aridzv Quote
BIGAL Posted January 29, 2022 Posted January 29, 2022 If you look at these 2 lines of code (setq ln (read-line f)) ;reads a line of a text file (setq pt (vlax-curve-getPointAtDist plineo (atof ln))) ; geta a point at distance ln So you can only have a single number (atof 10 0 0) will not work Quote
aridzv Posted January 30, 2022 Posted January 30, 2022 (edited) @BIGAL Hi and thanks for the answer. I've changed the txt file (see attached), but still getting the same resault - all the points are drawn at the pline start. thanks, Ari. testline.txt Edited January 30, 2022 by aridzv Quote
aridzv Posted January 30, 2022 Posted January 30, 2022 (edited) @BIGAL I entered in the command line (command "point" "10,0,0") and it worked, so I've made a small change to the lisp: (setq pt1 (strcase (strcat (rtos (car pt) 2 0) "," (rtos (cadr pt) 2 0) "," (rtos (caddr pt) 2 0)))) (command "._point" pt1) and I'm still getting the same resault Although this time the points come's in the right format, see attached screenshot. what I'm doing wrong here? thanks, Ari. Edited January 30, 2022 by aridzv Quote
BIGAL Posted January 30, 2022 Posted January 30, 2022 (edited) Worked for me maybe turn osnap off. Edited January 30, 2022 by BIGAL Quote
aridzv Posted January 31, 2022 Posted January 31, 2022 (edited) 12 hours ago, BIGAL said: Worked for me maybe turn osnap off. Yes,that was the problem... I've disabled the OSMODE and it worked. I've set the OSMODE in to a variable, then set it to 0, run the lisp and reset it to the original value. (setq osm (getvar "OSMODE")) ;; get current "OSMODE" in to avariable (setvar "OSMODE" 0) ;;set "OSMODE" to 0 . . . (setvar "OSMODE" osm) ;;reinstate "OSMODE" to its original value (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)));; simulate ESC to cancel the pline selection (vla-SendCommand doc (chr 27)) ;; simulate ESC to cancel the pline selection (princ) Thanks. Edited January 31, 2022 by aridzv Quote
eldon Posted January 31, 2022 Posted January 31, 2022 I think you can disable the Osnap temporarily by adding "_non" to the command statement. (command "._point" "_non" pt1) 1 Quote
aridzv Posted January 31, 2022 Posted January 31, 2022 @eldon 7 hours ago, eldon said: I think you can disable the Osnap temporarily by adding "_non" to the command statement. (command "._point" "_non" pt1) Nice... worked perfectly!! learned something new - THANKS!! Ari. Quote
Recommended Posts
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.