TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: HasanCAD on August 26, 2019, 03:43:43 AM

Title: Searching for a length lisp
Post by: HasanCAD on August 26, 2019, 03:43:43 AM
Hi,

I am wondering if there a lisp to do this task
I have a poyline and want to add length for each segment as attached image 1
and the length as image 2

Thanks in advance
Title: Re: Searching for a length lisp
Post by: CAB on August 26, 2019, 08:15:18 AM
Like this?  http://www.lee-mac.com/intersectionslength.html
Title: Re: Searching for a length lisp
Post by: CAB on August 26, 2019, 08:17:05 AM
More routines-----------   Length and Area   ------------------
Length of Objects by CAB - pick each object & displays
the object type, length & a running total on the command line.
http://www.theswamp.org/index.php?topic=5891.0
http://www.theswamp.org/index.php?topic=5891.msg268984#msg268984
Lengthen Command with Options by CAB - lengthen command
with key press switch  from Lengthen to Shorten
http://www.theswamp.org/index.php?topic=23871.0
http://www.theswamp.org/index.php?topic=29270.0 Line Length Calculator by Lee Mac
http://www.lee-mac.com/intersectionslength.html  Line Length Calculator by Lee Mac
http://www.theswamp.org/index.php?topic=20345.0 Areas of objects by Mark Thomas
http://www.theswamp.org/index.php?topic=33671.0  Show Total by Andrea
Title: Re: Searching for a length lisp
Post by: BIGAL on August 27, 2019, 06:34:17 AM
CAB may have missed this one also http://www.lee-mac.com/polyinfo.html

Hansancad need the length of the curves also should be dimmed maybe with radial dim.
Title: Re: Searching for a length lisp
Post by: HasanCAD on August 28, 2019, 11:42:53 AM
How to avoid if there is a curved part and measure one side of polyine not 2 sides as attached image 2

Thanks in advance
Title: Re: Searching for a length lisp
Post by: ronjonp on August 28, 2019, 05:10:32 PM
You could use inters on the straight segments and remove the segments with bulges > 0. Here is some code to get the apparent intersection of 2 picked segments.
https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/need-lisp-please/m-p/8979192#M388932
Title: Re: Searching for a length lisp
Post by: BIGAL on August 29, 2019, 02:34:37 AM
Like Ronjonp copy existing pline, remove bulges, dim this pline then erase new pline, so dims should be in correct places.

Bulge remove fillet r 0 Last Polyline

Now where is that auto dim pline.
Title: Re: Searching for a length lisp
Post by: HasanCAD on August 31, 2019, 10:23:47 AM
Like Ronjonp copy existing pline, remove bulges, dim this pline then erase new pline, so dims should be in correct places.

Bulge remove fillet r 0 Last Polyline

Now where is that auto dim pline.

Up to here is OK and can do that
But dim shall measure both sites of Pline
how to delete duplicate dim  ?
Title: Re: Searching for a length lisp
Post by: BIGAL on September 03, 2019, 01:15:11 AM
Trying to find some time as the dims are created using the vertices points it will only ever dim once. Need a autodim pline.

Need some more time I need to redo a couple of routines that check a few things like pline direction. So left right are correct.

Code: [Select]
; dimension a pline from vertices
; does not support bulges
; By AlanH Consulting info@alanh.com.au
; SEP 2019

(defun c:AHpldim ( / lst x y lst2 pt3 pt)
(setq plent (entsel "Pick pline near start end"))
(setq pt  (cadr plent) )
(setq obj (vlax-ename->vla-object (car plent)))
(setq pt1 (vlax-curve-getstartpoint obj))
(setq pt2 (vlax-curve-getendpoint obj))

(setq offd (getdist "Enter offset distance  "))

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(setq dir (ah:butts 1 "h"  '("Left or right" "Right" "Left")))

(if plent (setq lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car plent))))))

(if (< (distance pt pt1)(distance pt pt2))
(setq lst (reverse lst))
)

(setq x 0)

(repeat (- (length lst) 1)
(setq pt1  (nth x lst))
(setq pt2 (nth  (+ x 1) lst))
(if (= dir "Right")
(setq pt3 (polar pt1 (+ (/ pi 2.0)(angle pt1 pt2)) offd))
(setq pt3 (polar pt1 (- (angle pt1 pt2)(/ pi 2.0)) offd))
)
(command "Dim" "aligned" pt1 pt2  pt3 "" "exit" )
(setq x (+ x 1))
)

(princ)
)

(c:AHpldim)
Title: Re: Searching for a length lisp
Post by: BIGAL on September 03, 2019, 02:27:16 AM
HasanCad this should do what you want. make sure download Multi radio buttons.lsp

Code: [Select]
; dimension a pline from vertices
; does not support bulges
; By AlanH Consulting info@alanh.com.au
; SEP 2019

(defun AHpldim  (plent / lst pt1 pt2 pt3 pt offd oldsnap dir)

(setq oldsnap (getvar 'osmode))
(setvar 'osmode 0)

(setq pt  (cadr plent) )
(setq obj (vlax-ename->vla-object (car plent)))
(setq pt1 (vlax-curve-getstartpoint obj))
(setq pt2 (vlax-curve-getendpoint obj))

(setq offd (getdist "\nEnter offset distance  "))

(if (not AH:Butts)(load "Multi Radio buttons.lsp"))
(if (= but nil)(setq but 1))
(setq dir (ah:butts but "h"  '("Left or right" "Right" "Left")))

(command "copy" plent "" "0,0" "0,0")

(setvar 'filletrad 0)
(command "fillet" "p" "last")
(setq plent (entlast))

(setq lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget plent))))

(if (< (distance pt pt1)(distance pt pt2))
(setq lst (reverse lst))
)

(command "erase" plent "")

(setq x 0)

(repeat (- (length lst) 1)
(setq pt1  (nth x lst))
(setq pt2 (nth  (+ x 1) lst))
(if (= dir "Right")
(setq pt3 (polar pt1 (+ (/ pi 2.0)(angle pt1 pt2)) offd))
(setq pt3 (polar pt1 (- (angle pt1 pt2)(/ pi 2.0)) offd))
)
(command "Dim" "aligned" pt1 pt2  pt3 "" "exit" )
(setq x (+ x 1))
)
(setvar 'osmode oldsnap)
(princ)
)

(AHpldim  (entsel "\nPick pline near start end"))
Title: Re: Searching for a length lisp
Post by: HasanCAD on September 09, 2019, 03:54:05 AM
Sorry for late in answer
Thanks BIGAL Great work


HasanCad this should do what you want. make sure download Multi radio buttons.lsp

Code: [Select]
; dimension a pline from vertices
; does not support bulges
; By AlanH Consulting info@alanh.com.au
; SEP 2019
...
Title: Re: Searching for a length lisp
Post by: BIGAL on September 09, 2019, 05:19:25 AM
Not a problem, happy to help.