# Distance between points of Curve and line/intersection/s of 2 curves and dist t line.

## Recommended Posts

Hi from Bulgaria. I realy like making custom my autocad - so I will learn lisp soon.. But for now I need help with one routine.

I have a curve and I need a quick way to make linear dimensions to one axis that I've customly drawn say - x for example - to get the distance coords of the curve's points to this custom axis that i make so this axis is basicly arbitrary line.. I can't do this by hand because they are so many..

Other way to approach is - I have a net with intersections of x's and y's of curve and need to draw the linear dimension from intersections to one arbitrary line..

Also is good to get the coords in table or file so i can get it quick to excel for other calculations...

If someone can help me..

Thanks!

##### Share on other sites

Would you be able to upload a sample drawing just to clarify things please?

Also, is this a purely 2D problem?

Thanks

Lee

##### Share on other sites

Well I've made new drawing with the idea. It is pure 2d for me but you can make it 3d i think it will be usefull also.. The export in file or excel table of the points is very important because if they are many points - it will take a lot of time for me to get the coords and to type it in excel.

distance.dwg

##### Share on other sites

Give this a shot, see if it is what you require:

```[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:CurvPt  [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] doc spc file cEnt oPt cObj Int oFile pLst[b][color=RED])[/color][/b]

spc [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-activespace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-mspace[/color][/b] doc[b][color=RED])[/color][/b] :vlax-true[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-paperspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] file [b][color=RED]([/color][/b][b][color=BLUE]getfiled[/color][/b] [b][color=#ff00ff]"\nSelect Location for Excel File"[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] def_file def_file [b][color=#ff00ff]""[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]"csv"[/color][/b] [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] def_file file[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]exit[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entsel[/color][/b] [b][color=#ff00ff]"\nSelect Curve to Measure: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#ff00ff]"SPLINE"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] oPt [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] [b][color=#ff00ff]"\nSpecify Origin for Measurement <0,0,0> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] oPt [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] oPt [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cObj  [b][color=RED]([/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b] cEnt[b][color=RED])[/color][/b]
Int   [b][color=RED]([/color][/b][b][color=BLUE]getreal[/color][/b] [b][color=#ff00ff]"\nSpecify Measurement Interval <Control Points> : "[/color][/b][b][color=RED])[/color][/b]
oFile [b][color=RED]([/color][/b][b][color=BLUE]open[/color][/b] file [b][color=#ff00ff]"w"[/color][/b][b][color=RED])[/color][/b] i [b][color=#009900]-1[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]write-line[/color][/b] [b][color=#ff00ff]"X Distance,Y Distance"[/color][/b] oFile[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] Int
[b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getPointatDist[/color][/b] cObj [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] Int [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] i [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] i[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pLst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] pt pLst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pLst [b][color=RED]([/color][/b]vlax-list->3D-point
[b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray->list[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vlax-variant-value[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-ControlPoints[/color][/b] cObj[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]foreach[/color][/b] pt  pLst
[b][color=RED]([/color][/b][b][color=BLUE]write-line[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] pt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] oPt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]","[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] pt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] oPt[b][color=RED])[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] pi [b][color=#009900]2[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] oPt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] pt[b][color=RED])[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]close[/color][/b] oFile[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> No Spline Selected <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] vlax-list->3D-point  [b][color=RED]([/color][/b]lst[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] lst
[b][color=RED]([/color][/b]vlax-list->3D-point [b][color=RED]([/color][/b][b][color=BLUE]cdddr[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
```

##### Share on other sites

The above seems to get stuck in a loop when you specify an interval instead of using control points - but I can't work out why. It seems that the "vlax-curve-getPointatDist" is not reaching the end of the curve

##### Share on other sites

This seems to resolve the problem, but I am still unsure as to why the original post loops endlessly

```[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:CurvPt  [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] doc spc file cEnt oPt cObj Int oFile pLst[b][color=RED])[/color][/b]

spc [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-activespace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-mspace[/color][/b] doc[b][color=RED])[/color][/b] :vlax-true[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-paperspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] file [b][color=RED]([/color][/b][b][color=BLUE]getfiled[/color][/b] [b][color=#ff00ff]"\nSelect Location for Excel File"[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] def_file def_file [b][color=#ff00ff]""[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]"csv"[/color][/b] [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] def_file file[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]exit[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entsel[/color][/b] [b][color=#ff00ff]"\nSelect Curve to Measure: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#ff00ff]"SPLINE"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] oPt [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] [b][color=#ff00ff]"\nSpecify Origin for Measurement <0,0,0> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] oPt [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] oPt [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cObj  [b][color=RED]([/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b] cEnt[b][color=RED])[/color][/b]
Int   [b][color=RED]([/color][/b][b][color=BLUE]getreal[/color][/b] [b][color=#ff00ff]"\nSpecify Measurement Interval <Control Points> : "[/color][/b][b][color=RED])[/color][/b]
oFile [b][color=RED]([/color][/b][b][color=BLUE]open[/color][/b] file [b][color=#ff00ff]"w"[/color][/b][b][color=RED])[/color][/b] i [b][color=#009900]-1[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]write-line[/color][/b] [b][color=#ff00ff]"X Distance,Y Distance"[/color][/b] oFile[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] Int
[b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getPointatDist[/color][/b] cObj [b][color=RED]([/color][/b][b][color=BLUE]*[/color][/b] Int i[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]>[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]distance[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getEndPoint[/color][/b] cObj[b][color=RED])[/color][/b] pt[b][color=RED])[/color][/b] Int[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pLst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] pt pLst[b][color=RED])[/color][/b] i [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] i[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pLst [b][color=RED]([/color][/b]vlax-list->3D-point
[b][color=RED]([/color][/b][b][color=BLUE]vlax-safearray->list[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vlax-variant-value[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-ControlPoints[/color][/b] cObj[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]foreach[/color][/b] pt  pLst
[b][color=RED]([/color][/b][b][color=BLUE]write-line[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] pt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] oPt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]","[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] pt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] oPt[b][color=RED])[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] pi [b][color=#009900]2[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] oPt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] pt[b][color=RED])[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]close[/color][/b] oFile[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> No Spline Selected <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] vlax-list->3D-point  [b][color=RED]([/color][/b]lst[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] lst
[b][color=RED]([/color][/b]vlax-list->3D-point [b][color=RED]([/color][/b][b][color=BLUE]cdddr[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
```

##### Share on other sites

WOw:?. It works perfectly! Exactly what i need for first task. Thanks!

The problem with intersections still remains... To get the distance from intersections of spline with choosed lines to one axis...

Here is my new need - I hope that I'm very insolent.

distance2.dwg

##### Share on other sites

My function already copes with this.

Can't you just select the curve and specify the measurement interval to be the distance between your lines.

##### Share on other sites

I've tried by it gets the measurement interval from the curve not from the line that i use for axis. And measures the distance in equal spaces of the curve not of the line. So where the curve bends it calculate the length also and the points are shifting.

Also there are places that i've need more datail so I will make more intersections and they will be not in equal spaces ... If there is an option to choose lines which intersect and find the distance of intersections of curve to new specific orgin.

But still if the measurement interval works for choosed equal line intervals not equal curve intervals it will make my life easier I will do by hand other intersections that are not equal..

distance3.dwg

##### Share on other sites

Ahh, of course - my apologies

Will see what I can do

##### Share on other sites

Give this a shot:

```[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:CurvInt  [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] doc spc ss i j [b][color=#009900]1[/color][/b]L oPt cEnt cObj Int iLst pt[b][color=RED])[/color][/b]

spc [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-activespace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-mspace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-paperspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vla-get-modelspace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] file [b][color=RED]([/color][/b][b][color=BLUE]getfiled[/color][/b] [b][color=#ff00ff]"\nSelect Location for Excel File"[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] def_file def_file [b][color=#ff00ff]""[/color][/b][b][color=RED])[/color][/b] [b][color=#ff00ff]"csv"[/color][/b] [b][color=#009900]1[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] def_file file[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]exit[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]prompt[/color][/b] [b][color=#ff00ff]"\nSelect Vertical Lines..."[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#ff00ff]"LINE,*POLYLINE"[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"CTAB"[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]410[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"CTAB"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009900]67[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=#ff00ff]"TILEMODE"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] oFile [b][color=RED]([/color][/b][b][color=BLUE]open[/color][/b] file [b][color=#ff00ff]"w"[/color][/b][b][color=RED])[/color][/b] i [b][color=#009900]0[/color][/b] j [b][color=#009900]1[/color][/b] [b][color=#009900]1[/color][/b]L [b][color=RED]([/color][/b][b][color=BLUE]chr[/color][/b] [b][color=#009900]44[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]<=[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] i [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] i[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]sslength[/color][/b] ss[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] [b][color=#009900]1[/color][/b]L [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#009900]1[/color][/b]L [b][color=RED]([/color][/b][b][color=BLUE]itoa[/color][/b] i[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]chr[/color][/b] [b][color=#009900]44[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]write-line[/color][/b] [b][color=#009900]1[/color][/b]L oFile[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] oPt [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] [b][color=#ff00ff]"\nSpecify Origin <0,0,0> : "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] oPt [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] oPt [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cEnt [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entsel[/color][/b] [b][color=#ff00ff]"\nSelect Curve to Measure: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]member[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]0[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]entget[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=#ff00ff]"LINE"[/color][/b] [b][color=#ff00ff]"LWPOLYLINE"[/color][/b] [b][color=#ff00ff]"POLYLINE"[/color][/b] [b][color=#ff00ff]"SPLINE"[/color][/b] [b][color=#ff00ff]"ARC"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] cObj [b][color=RED]([/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b] cEnt[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]foreach[/color][/b] Obj  [b][color=RED]([/color][/b][b][color=BLUE]vl-sort[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]mapcar[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]vlax-ename->vla-object[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vl-remove-if[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]listp[/color][/b]
[b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b]x1 x2[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]<[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getStartPoint[/color][/b] x1[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-curve-getStartPoint[/color][/b] x2[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Int [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke[/color][/b] cObj
[b][color=DARKRED]'[/color][/b]IntersectWith Obj
[b][color=Blue]acExtendNone[/color][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] Int
[b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] iLst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]-[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Int[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] oPt[b][color=RED])[/color][/b][b][color=RED])[/color][/b] iLst[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] pt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] oPt[b][color=RED])[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] pi [b][color=#009900]2[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] oPt[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cadr[/color][/b] pt[b][color=RED])[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=#009900]0[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] iLst [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=#009999]0.0[/color][/b] iLst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]write-line[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#ff00ff]"Curve "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]itoa[/color][/b] j[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]chr[/color][/b] [b][color=#009900]44[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b]Pnt->Csv iLst[b][color=RED])[/color][/b][b][color=RED])[/color][/b] oFile[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] j    [b][color=RED]([/color][/b][b][color=BLUE]1+[/color][/b] j[b][color=RED])[/color][/b] iLst [b][color=BLUE]nil[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]close[/color][/b] oFile[b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#ff00ff]"\n<!> No Lines/*Polylines Selected <!>"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] Pnt->Csv  [b][color=RED]([/color][/b]lst [b][color=BLUE]/[/color][/b] Str[b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Str [b][color=#ff00ff]""[/color][/b][b][color=RED])[/color][/b]
[b][color=RED]([/color][/b][b][color=BLUE]while[/color][/b] lst
[b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Str [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]rtos[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]chr[/color][/b] [b][color=#009900]44[/color][/b][b][color=RED])[/color][/b] Str[b][color=RED])[/color][/b]
lst [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b]
Str[b][color=RED])[/color][/b]
```

##### Share on other sites

It works!!! Just the output is little bit odd in 2 cells not every new value in new cell... also there are no y values registered in csv file only number of frame and x... But I can work from now one in autocad part it do the job. Thanks a lot you deserve 6 at math masters degree!!!

##### Share on other sites

If I want to measure another curve with the same intersections but the mesurments of the first is no longer needed because i've recoded it how can I delete them without leaving the script - now I do it with exit(esc) script and Ctrl+z but the selection is lost and then for another curve i have to run the script again and chose the same interstections - because i don't want to select the same intercection(vertical) lines again just to use last selected lines?

Is there easy way or again coding like function "delete last measurements" but stay in the command to select another curve?

##### Share on other sites

You mean you want to get rid of the dimension lines?

##### Share on other sites

Yes and to stay in the command because it will leave selection and just choose another curve to measuere..because when i make another measurement the new coords overlap with old ones and I cannot see them. So I leave command delete them and then again do comand and same selection of vertical(intersection) lines..

##### Share on other sites
Just the output is little bit odd in 2 cells not every new value in new cell... also there are no y values registered in csv file only number of frame and x...

The output seems to be fine to me? - I know there is no y-value, but I thought you only wanted x values?

See pic attached for how mine appears in csv.

##### Share on other sites

For deletion of dimension lines:

```(defun c:CurvInt  (/ doc spc ss i j 1L oPt cEnt cObj Int iLst pt dObjlst)

spc (if (zerop (vla-get-activespace doc))
(if (= (vla-get-mspace doc) :vlax-true)
(vla-get-modelspace doc)
(vla-get-paperspace doc))
(vla-get-modelspace doc)))

(setq file (getfiled "\nSelect Location for Excel File"
(if def_file
def_file
"")
"csv"
1))
(if (not (setq def_file file))
(exit))

(prompt "\nSelect Vertical Lines...")
(if (setq ss (ssget (list (cons 0 "LINE,*POLYLINE")
(if (getvar "CTAB")
(cons 410 (getvar "CTAB"))
(cons 67 (- 1 (getvar "TILEMODE")))))))
(progn
(setq oFile (open file "w")
i     0
j     1
1L    (chr 44))
(while (<= (setq i (1+ i)) (sslength ss))
(setq 1L (strcat 1L (itoa i) (chr 44))))
(write-line 1L oFile)
(setq oPt (getpoint "\nSpecify Origin <0,0,0> : "))
(or oPt (setq oPt '(0 0 0)))
(while (and (setq cEnt (car (entsel "\nSelect Curve to Measure: ")))
(member (cdr (assoc 0 (entget cEnt)))
'("LINE" "LWPOLYLINE" "POLYLINE" "SPLINE" "ARC")))
(setq cObj (vlax-ename->vla-object cEnt))
(foreach Obj  (vl-sort
(mapcar 'vlax-ename->vla-object
(vl-remove-if
'listp
'(lambda (x1 x2)
(< (car (vlax-curve-getStartPoint x1))
(car (vlax-curve-getStartPoint x2)))))
(setq Int (vlax-invoke
cObj
'IntersectWith
Obj
acExtendNone))
(if Int
(progn
(setq iLst (cons (- (car Int) (car oPt)) iLst)
(setq dObjlst (cons
spc
(vlax-3D-point pt)
(vlax-3D-point (list (car pt) (cadr oPt) 0))
(vlax-3D-point pt)
(/ pi 2))
dObjlst))
(setq dObjlst (cons
spc
(vlax-3D-point pt)
(vlax-3D-point (list (car oPt) (cadr pt) 0))
(vlax-3D-point pt)
0)
dObjlst)))
(setq iLst (cons 0.0 iLst))))
(write-line (strcat "Curve " (itoa j) (chr 44) (Pnt->Csv iLst)) oFile)
(setq j    (1+ j)
iLst nil)
(initget "Yes No")
(if (not (eq "No" (getkword "\nDelete Old Dimensions? [Yes/No] <Yes>: ")))
(mapcar 'vla-delete dObjlst))
(setq dObjlst nil))
(close oFile))
(princ "\n<!> No Lines/*Polylines Selected <!>"))
(princ))

(defun Pnt->Csv  (lst / Str)
(setq Str "")
(while lst
(setq Str (strcat (rtos (car lst)) (chr 44) Str)
lst (cdr lst)))
Str)

```

##### Share on other sites

Before i need only one coord but now I have different view of the ship so i need other axis coords..For the output is nice to have 2 coords even all 3(don't know if they became handy in future in this project - I know that i will need to calculate the volumes and placment of loads so maybe will need to go 3d it will be usefull to draw line and find distance of curve and etc.....) in separate cells because i'm using it for different 2d views so vertical lines became horizontal in other projection view and i'm lieing the script that horizontal lines are vertical (This I fix it easy just changed (prompt "\nSelect Vertical Lines..." with prompt "\nSelect Intersection Lines..." )( I'm using the same script to measure a lot of distances - when I need distance I just make a line that intersect curve and using this script find the needed distance.) It is usefull to have values in table like this because I'm using - function in excel called "Transpose".. To reorder the information because first sheet tables are nice visual and second sheet and in third sheet I use for preparing (CONCATENATEfunction )and drawing back information to Autocad- and to make full integration with your script and this, I first measure in autocad see the results then when I make change in calculations I only type it in first tables they transport it to third sheet there i just ctrl+c,ctrl+v back in Autocad and it draws it automaticlly... So the process becames semi-automatic.

So it is the idea like drawing by coords then... See atached file... So if this script outputs first tables(in sheet "Gettedcoordsfrom Autocad") it will be great.. See all 3 sheets for the process..

Now the output is only in one cell with commas. it is not like you show on the picture.. The separation of cell didn't happen to me:

Basicly i need x,y,z output and name of curve and number of intersection... If it can't happen just x,y will be wonderfull..

By the way deleting script works smoothly!!!

example.zip

##### Share on other sites

Is it exporting to a .csv file?

##### Share on other sites

Yes.. this is the content of .csv file opened in excel...

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.