Author Topic: Searching for a length lisp  (Read 556 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1302
Searching for a length lisp
« 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

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Re: Searching for a length lisp
« Reply #1 on: August 26, 2019, 08:15:18 AM »
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10362
Re: Searching for a length lisp
« Reply #2 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
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

BIGAL

  • Bull Frog
  • Posts: 300
  • 30 + years of using Autocad
Re: Searching for a length lisp
« Reply #3 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.
A man who never made a mistake never made anything

HasanCAD

  • Swamp Rat
  • Posts: 1302
Re: Searching for a length lisp
« Reply #4 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

ronjonp

  • Needs a day job
  • Posts: 7025
Re: Searching for a length lisp
« Reply #5 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

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

BIGAL

  • Bull Frog
  • Posts: 300
  • 30 + years of using Autocad
Re: Searching for a length lisp
« Reply #6 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.
A man who never made a mistake never made anything

HasanCAD

  • Swamp Rat
  • Posts: 1302
Re: Searching for a length lisp
« Reply #7 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  ?

BIGAL

  • Bull Frog
  • Posts: 300
  • 30 + years of using Autocad
Re: Searching for a length lisp
« Reply #8 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)
« Last Edit: September 03, 2019, 01:53:28 AM by BIGAL »
A man who never made a mistake never made anything

BIGAL

  • Bull Frog
  • Posts: 300
  • 30 + years of using Autocad
Re: Searching for a length lisp
« Reply #9 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"))
A man who never made a mistake never made anything

HasanCAD

  • Swamp Rat
  • Posts: 1302
Re: Searching for a length lisp
« Reply #10 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
...

BIGAL

  • Bull Frog
  • Posts: 300
  • 30 + years of using Autocad
Re: Searching for a length lisp
« Reply #11 on: September 09, 2019, 05:19:25 AM »
Not a problem, happy to help.
A man who never made a mistake never made anything