Jump to content

Looking for a lisp to take add points from an excel file along a line


DDS-NCorette

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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 by Ish
Modified
Link to comment
Share on other sites

  • 2 months later...

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

Capture.PNG

testline.txt

Edited by aridzv
Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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

Capture.PNG

testline.txt

Edited by aridzv
Link to comment
Share on other sites

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

Capture1.PNG

Edited by aridzv
Link to comment
Share on other sites

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 by aridzv
Link to comment
Share on other sites

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

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