Jump to content

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


Recommended Posts

Posted

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

Posted

To Get you started just read values out of the file then use the following.

 

 

Posted

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.

Posted

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

Posted

I dont understand just use

 

(setq pt (vlax-curve-getPointAtDist plineo (atof ln)))
(command "point" pt)

 

Posted

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
Posted

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.

  • Like 1
Posted (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 by Ish
Modified
  • 2 months later...
Posted (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. 

Capture.PNG

testline.txt

Edited by aridzv
Posted

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 

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

Capture.PNG

testline.txt

Edited by aridzv
Posted (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.

Capture1.PNG

Edited by aridzv
Posted (edited)

Worked for me maybe turn osnap off.

Edited by BIGAL
Posted (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 by aridzv
Posted

I think you can disable the Osnap temporarily by adding "_non" to the command statement.

 

(command "._point" "_non" pt1)

  • Thanks 1
Posted

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

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