Jump to content
jes_g

Find the closest point on the polyline, creaet vertex and export to a spreadsheet

Recommended Posts

jes_g

Hello there,

 

Merry Christmas!

 

I am new in LISP and I don't know where to start from. For clarity, please refer to the snapshot provided.

 

I am not quite familiar with AutoCAD terminology though, but I'll try to explain my problem clear. Basically, we have polylines and points having their coordinates (these small blue rectangulars). What we need to do is:

 

Find the closest on the polyline from the "blue rectangular"

Create the vertex on THAT point

Export to Excel files the following parameters: number, Coordinates of each vertex, distances between them, '1' if the line contains newly-created vertex

The output files are expected to look like:

 

1. XY_Coords.xls:

 

Node X Y

1 359.898 163.788

2 358.514 164.124

3 358.423 164.131

4 358.354 164.119

5 358.26 164.07

6 358.198 164.005

7 358.153 163.91

8 355.136 152.963

9 354.962 152.691

 

 

2. Lines.xls

NodeA NodeB Distance Load

1 2 1.424202233 0

2 3 0.091268834 0

3 4 0.070035705 1

4 5 0.106004717 0

5 6 0.089827613 0

6 7 0.10511898 0

7 8 11.35513531 1

8 9 0.322893171 0

9 10 0.22220036 0

10 11 0.299247389 0

 

mgpUaR

 

Please ask questions if you need some clarifications.

 

Your help is greatly appreciated.

 

 

Thank you

 

Best wishes,

 

Jes G

 

https://ibb.co/mgpUaRsnapshot.jpg

Share this post


Link to post
Share on other sites
BIGAL

Using the VL option getclosestpointto it will work out the point for you, then add the vertex point. I am not sure about your output what it is being used for. It looks like something that has already been done. Did you do a bit of a search.

Share this post


Link to post
Share on other sites
jes_g

Dear BIGAL. Thank you for your comment. Actually, nothing has been done so far, this is just my idea of what output would look like. I did not do the search yet because I don't know exactly what to search for. If you could guide me a bit on this, it would be much appreciated. Thank you

Share this post


Link to post
Share on other sites
BIGAL

This is more a chainage and offset type subject, you could do a chxxx x,y offset ptx,y and so on I dont think you need the other points.

 

It would be best to try to explain exactly what you want and and why ! Then a code example I am sure will be found.

 

What you want can be done pretty easy there is VL functions to calculate the answers.

Share this post


Link to post
Share on other sites
jes_g

Basically, I am doing a LV study. I need to develop/find algorithm that translates GIS provided by the utility, into models understood by the software to run the analysis. Ideally, I expect the script to loop because I will have a lot of GIS AutoCAD files.

These "blue rectangulars" are consumers. That is why I need to relate them to a closest line/point on the line meaning that this line has a consumer.

Re output files, basically the first file, XY_coords.xls, will provide all the vertexes' coordinates present in GIS AutoCAD file, while the second file, Lines.xls, will provide a list of lines, where NodeA is the first vertex, and NodeB is the end vertex. I used to do this using PolyInfo lisp routing developed by Lee Mac http://www.lee-mac.com/polyinfo.html but with this I had to select each polyline, then the routine exported data to .txt file, and I copied everything into Excel. Now it is more complicated and without knowing AutoLISP, it's quite overwhelming.

 

I hope I made it clearer. Please ask questions if you need more clarifications

Thank you

Share this post


Link to post
Share on other sites
jes_g

Dear BIGAL, your help is greatly appreciated

Share this post


Link to post
Share on other sites
BIGAL

Sorry been a bit busy of late renovating a house. Its a case of bolting together some off the shelf stuff. Some one may step up and offer help.

 

Here is a start

 

; simple pline and point offset report
; By Alan H
; Vertice closest is needed

(defun C:simplpt ( / obj pt1 pt2 len dist)
(setq obj (vlax-ename->vla-object (car (entsel "\nPick Pline object"))))
(while (setq pt1 (getpoint "Pick point near pline Enter to exit"))
(setq pt2 (vlax-curve-getclosestpointto obj pt1))
(command "line" pt1 pt2 "")
(setq dist (vla-get-length (vlax-ename->vla-object (entlast))))
(setq len (vlax-curve-getdistatpoint obj pt2))
(alert (strcat "Point is " (rtos dist 2 2) " off the line \n\nand is " (rtos len 2 2) " along the line \n\nand is x away from the x vertice of line"))
)

Edited by BIGAL

Share this post


Link to post
Share on other sites
devitg
I am doing a LV study.

 

What it is LV study ???

 

Please upload your both XLS sample , to use it as template. But it will be easy to save as ComaSeparatedValue also known as CSV file , the you can open it on XLS

Share this post


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.   Paste as plain text instead

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