Jump to content

Recommended Posts

Posted (edited)

Hello,
 

This is my first post ever on here so I apologize if this is not formatted correctly.

 

Basically, I am looking for a lisp that can auto dimension the distance between 2 lots along a line. For example:

 

image.thumb.png.398d9aade0d9bfd622457f0e033f321b.png

 

The pink line is setback 6m from the blue line and I would want a dimension the distance between each lot along the pink line. I have tried using some auto dimension lisps, but they only really work for total length of each line.

 

Does anyone have a lisp recommendation for this type of dimensioning?

 

Thank you so much for your help!

Edited by 7empest
  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • 7empest

    13

  • BIGAL

    6

  • pkenewell

    2

  • ronjonp

    1

Top Posters In This Topic

Posted Images

Posted

Welcome! If you break those into segments along the lot lines then it would be easy to add a length field at the midpoints.

 

 

Posted
34 minutes ago, ronjonp said:

Welcome! If you break those into segments along the lot lines then it would be easy to add a length field at the midpoints.

 

 

Thank you for the reply.

 

With the link that you have attached, I would need to make an account. Is what you linked some sort of lisp that will break up each frontage line between each lot?

 

I know of the "break" tool in autocad, but when working on a subdivision with 2000+ lots, it would take longer to break them all up than to manually dimension them.

 

Unless what you've linked solves that?

 

Thank you again for your reply!

Posted

Most land development plans have 2 choices individual frontages or a pline between intersecting roads. Sometimes both.

 

You need to post a dwg with multiple dimensions not just 2. So get a better idea of dimension variations.

Posted

Attached is an example. The pink lines are the setbacks from which the frontages need to be measured between the two lots. But i would need the lisp to work with other drawings as well, not just this specific one.

I have dimensioned this one before so you can unfreeze the layer to see those dimensions.

Testcad.dwg

Posted

To better explain what I want to do:

 

- I want to isolate LOT_LINES and LOT_CHORD FRONTAGE

- Select everything

- have the lisp spit out the dimensions between each lot along the LOT_CHORD FRONTAGE

Posted (edited)
4 minutes ago, pkenewell said:

You should contact @Lee Mac from his contact page and see if he will alter it for you. I personally would prefer not to monkey with his code.


Thank you, I have messaged them

Edited by 7empest
Posted (edited)

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-for-creating-dimension-at-intersections-of-selected-lines/td-p/6800455

 

So I have found this code, however, I can't seem to get it to work. After I create it in a .lsp format, it prompts when I type in "diminterns" but when I select a line or pline, nothing happens.

 

Is anyone able to see if the same thing is happening to them?

 

Thanks everyone!

EDIT: I figured it out. I needed to select the lot lines and the curve it should be measuring from!

Edited by 7empest
Posted

Thought I posted this yesterday.

 

Tried out lee's code and it seems to do what you want if you understand how it works. Ok why a dim if happy with just the label of distance sitting above line.

 

Re label on top or below line is controlled by the direction of say the pline. 

 

Try this change will auto select correct objects.

(defun c:IntLenM ( / *error* ss i )

  (defun *error* ( msg )
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )

  (if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (getvar 'CLAYER))))))
    (princ "\n--> Current Layer Locked.")
	(progn
	(setq lay (cdr (assoc 8 (entget (car (entsel "\nPick object for layer "))))))
    (if (setq ss (ssget "X" (list (cons 0 "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")(cons 8 lay)(cons 410 "Model"))))
      (repeat (setq i (sslength ss))
        (LM:IntersectionLengths (ssname ss (setq i (1- i))))
      )
    )
  )
  )
  
  (princ)
)

You need plines else frontages of 2 objects will not work properly.

Posted
On 23/08/2024 at 23:58, BIGAL said:

Thought I posted this yesterday.

 

Tried out lee's code and it seems to do what you want if you understand how it works. Ok why a dim if happy with just the label of distance sitting above line.

 

Re label on top or below line is controlled by the direction of say the pline. 

 

Try this change will auto select correct objects.

(defun c:IntLenM ( / *error* ss i )

  (defun *error* ( msg )
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )

  (if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (getvar 'CLAYER))))))
    (princ "\n--> Current Layer Locked.")
	(progn
	(setq lay (cdr (assoc 8 (entget (car (entsel "\nPick object for layer "))))))
    (if (setq ss (ssget "X" (list (cons 0 "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")(cons 8 lay)(cons 410 "Model"))))
      (repeat (setq i (sslength ss))
        (LM:IntersectionLengths (ssname ss (setq i (1- i))))
      )
    )
  )
  )
  
  (princ)
)

You need plines else frontages of 2 objects will not work properly.


Thank you for your reply.. When I try this lsp I am getting the following error: image.png.edbd57ac01d355c6682e1728e5b18527.png

Posted (edited)
2 hours ago, 7empest said:

Thank you for your reply.. When I try this lsp I am getting the following error:

You need to download the (LM: intersectionlengths) function from your link above and add it to the lisp file before using BIGAL's code.

Edited by pkenewell
Posted
59 minutes ago, pkenewell said:

You need to download the (LM: intersectionlengths) function from your link above and add it to the lisp file before using BIGAL's code.

Got it! Thank you

Posted
;;-------------=={ Length Between Intersections }==-----------;;
;;                                                            ;;
;;  Displays the length of segments of a curve divided at     ;;
;;  intersections with other objects.                         ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Version 1.4    -    26-04-2011                            ;;
;;------------------------------------------------------------;;

(defun c:IntLen ( / *error* _iscurveobject e )

  (defun *error* ( msg )
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )

  (defun _IsCurveObject ( entity / param )
    (and
      (not
        (vl-catch-all-error-p
          (setq param
            (vl-catch-all-apply 'vlax-curve-getendparam (list entity))
          )
        )
      )
      param
    )
  )

  (if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (getvar 'CLAYER))))))
    (princ "\n--> Current Layer Locked.")  
    (while
      (progn (setvar 'ERRNO 0) (setq e (car (entsel)))
        (cond
          (
            (= 7 (getvar 'ERRNO))

            (princ "\n--> Missed, Try again.")
          )
          (
            (eq 'ENAME (type e))

            (if (_iscurveobject e)
              (LM:IntersectionLengths e)
              (princ "\n--> Invalid Object Selected.")
            )
            t
          )
        )
      )
    )
  )
  (princ)
)

;;------------------------------------------------------------;;

(defun c:IntLenM ( / *error* ss i )

  (defun *error* ( msg )
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )

  (if (= 4 (logand 4 (cdr (assoc 70 (tblsearch "LAYER" (getvar 'CLAYER))))))
    (princ "\n--> Current Layer Locked.")
    (if (setq ss (ssget '((0 . "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE"))))
      (repeat (setq i (sslength ss))
        (LM:IntersectionLengths (ssname ss (setq i (1- i))))
      )
    )
  )

  (princ)
)

;;------------------------------------------------------------;;

(defun LM:IntersectionLengths

  ( e  ;; Entity name
    
    / *error* _startundo _endundo _groupbynum _sortbyparam _makereadable _isannotative _uniquefuzz
      a acspc c d d1 d2 da e i l ll m o ss ta to ts ur x y
  )

  (setq acdoc (cond ( acdoc ) ( (vla-get-activedocument (vlax-get-acad-object)) ))
        acspc (vlax-get-property acdoc (if (= 1 (getvar 'CVPORT)) 'Paperspace 'Modelspace))
  )

  (defun *error* ( msg )
    (if acdoc (_EndUndo acdoc))
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
  )

  (defun _StartUndo ( doc ) (_EndUndo doc)
    (vla-StartUndoMark doc)
  )

  (defun _EndUndo ( doc )
    (if (= 8 (logand 8 (getvar 'UNDOCTL))) (vla-EndUndoMark doc))
  )

  (defun _GroupByNum ( l n / r)
    (if l
      (cons
        (reverse (repeat n (setq r (cons (car l) r) l (cdr l)) r))
        (_GroupByNum l n)
      )
    )
  )

  (defun _SortbyParam ( e l )
    (vl-sort l '(lambda ( a b ) (< (vlax-curve-getParamatPoint e a) (vlax-curve-getParamatPoint e b))))
  )

  (defun _MakeReadable ( a )
    (
      (lambda ( a )
        (cond
          ( (and (> a (/ pi 2)) (<= a pi))

            (- a pi)
          )
          ( (and (> a pi) (<= a (/ (* 3 pi) 2)))

            (+ a pi)
          )
          ( a )
        )
      )
      (rem a (* 2 pi))
    )
  )

  (defun _isAnnotative ( style / object annotx )
    (and
      (setq object (tblobjname "STYLE" style))
      (setq annotx (cadr (assoc -3 (entget object '("AcadAnnotative")))))
      (= 1 (cdr (assoc 1070 (reverse annotx))))
    )
  )

  (defun _uniquefuzz ( lst fuzz )
    (if lst
      (cons (car lst)
        (_uniquefuzz
          (vl-remove-if '(lambda ( x ) (equal x (car lst) fuzz)) (cdr lst)) fuzz
        )
      )
    )
  )

  (setq ts
    (/ (getvar 'textsize)
      (if (_isAnnotative (getvar 'textstyle))
        (cond ( (getvar 'cannoscalevalue) ) ( 1.0 )) 1.0
      )
    )
  )

  (_StartUndo acdoc)
  
  (vla-getBoundingBox (setq o (vlax-ename->vla-object e)) 'll 'ur)

  (mapcar '(lambda ( x ) (set x (vlax-safearray->list (eval x)))) '(ll ur))

  (if
    (setq l
      (_sortbyparam e
        (_uniquefuzz
          (apply 'append
            (repeat
              (setq i
                (sslength
                  (ssdel e
                    (setq ss
                      (ssget "_C" (trans ur 0 1) (trans ll 0 1) '((0 . "ARC,CIRCLE,ELLIPSE,*LINE")))
                    )
                  )
                )
              )
              (setq l
                (cons
                  (_groupbynum
                    (vlax-invoke o 'intersectwith
                      (vlax-ename->vla-object (ssname ss (setq i (1- i)))) acextendnone
                    )
                    3
                  )
                  l
                )
              )
            )
          )
          1e-8
        )
      )
    )
    (if (not (vlax-curve-isClosed e))
      (progn
        (or
          (equal (vlax-curve-getStartParam e) (vlax-curve-getParamatPoint e (car l)) 0.001)
          (setq l (cons (vlax-curve-getStartPoint e) l))
        )
        (or
          (equal (vlax-curve-getEndParam e) (vlax-curve-getParamatPoint e (last l)) 0.001)
          (setq l (append l (list (vlax-curve-getEndPoint e))))
        )
      )
      (setq c l)
    )
    (if (vlax-curve-isClosed e)
      (setq l (list (vlax-curve-getStartPoint e)) c l)
      (setq l (list (vlax-curve-getStartPoint e) (vlax-curve-getEndPoint e)))
    )
  )

  (while (cadr l) (setq x (car l) y (cadr l) l (cdr l))
    (setq m
      (vlax-curve-getPointatDist e
        (/ (+ (vlax-curve-getDistatPoint e y) (vlax-curve-getDistAtPoint e x)) 2.)
      )
    )
    (setq d
      (abs
        (- (vlax-curve-getDistatPoint e y) (vlax-curve-getDistAtPoint e x))
      )
    )
    (setq a
      (angle '(0. 0. 0.)
        (vlax-curve-getFirstDeriv e (vlax-curve-getParamatPoint e m))
      )
    )
    (setq ta (_makereadable a))

    (setq to (vla-AddText acspc (rtos d) (vlax-3D-point '(0. 0. 0.)) ts))
    (vla-put-Alignment to acAlignmentMiddleCenter)
    (vla-put-TextAlignmentPoint to (vlax-3D-point (polar m (+ ta (/ pi 2.)) (* 1.1 ts))))
    (vla-put-rotation to ta)    
  )
  
  (if (vlax-curve-isclosed e)
    (progn
      (if (= 1 (length c)) (setq c (append c c)))
      (setq d
        (+
          (setq d1 (vlax-curve-getDistatPoint e (car c)))
          (setq d2 (- (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) (vlax-curve-getdistatpoint e (last c))))
        )
      )                  
      (setq m
        (vlax-curve-getPointatDist e
          (if (< d1 (setq da (/ (+ d1 d2) 2.)))
            (setq da (- (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) (- da d1)))
            (setq da (- da d2))
          )
        )
      )
      (setq a
        (angle '(0. 0. 0.)
          (vlax-curve-getFirstDeriv e (vlax-curve-getParamatPoint e m))
        )
      )
      (setq ta (_makereadable a))

      (setq to (vla-AddText acspc (rtos d) (vlax-3D-point '(0. 0. 0.)) ts))
      (vla-put-Alignment to acAlignmentMiddleCenter)
      (vla-put-TextAlignmentPoint to (vlax-3D-point (polar m (+ ta (/ pi 2.)) (* 1.1 ts))))
      (vla-put-rotation to ta)
    )
  )

  (_EndUndo acdoc)
  (princ)
)

;;------------------------------------------------------------;;

(vl-load-com)
(princ)
(princ "\n:: IntLen.lsp | Version 1.4 | © Lee Mac 2011 www.lee-mac.com ::")
(princ "\n:: Type \"IntLen\" or \"IntLenM\" to Invoke ::")
(princ)

;;------------------------------------------------------------;;
;;                         End of File                        ;;
;;------------------------------------------------------------;;


It's me again. So, out of the all the lisps I have found that provide dimensions between intersections I think I would prefer to use this one.

 

Credit to Lee Mac with this code (https://lee-mac.com/intersectionslength.html)

 

There are just 3 issues I am encountering that I hope someone here may be able to help with:

 

1. The text is offset from the the line by what looks to be 2m.. Is there any way to get the text/dim to be placed on the pink line? (see image below)

image.png.6e084f2867e280fe37ce0457cac9f90d.png

 

2.  Second, for some reason I can't get it to display the dimensions at 2 decimal places when its a whole number I.e. 12.80 (as above), 9.10, 12.10, etc. but it displays it fine if it is not a whole number i.e. 12.81, 9.11, 12.15, etc.

I have tried adjusting "dwgunits" and "units" to 2 decimal places but no luck. Any one have any suggestions for this?

 

3. Third and final issue, around curves it doesn't seem to do it at the intersecting lines when there is an end point of a line in-between the intersecting points. Instead, it will dimension it to the end point of the line and add another dimension after it to the intersecting point. This is hard to explain but the image below should help explain what I mean. Is there any way to fix this?
image.png.31486d507ac8a85bc2c2dba586db44cc.png

Posted (edited)

1 need in code to find where the offset value is and override with an extra step at start of program pick 2 points to get offset distance. Maybe 

(/ (+ (vlax-curve-getDistatPoint e y) (vlax-curve-getDistAtPoint e x)) 2.)

 

2 may need 2 mods in the code there may be a RTOS function like (rtos x 2 2 ) the 1st 2 is decimal the second is number of decimal places, you can check a value and if its "18.1" force it to be "18.10" 

 

3 as I suggested in earlier post you need continuous plines not segments, then Lee's code will work. The program does not look for connecting objects.

 

4 Lee often comments here so he may respond to items 1 & 2.

Edited by BIGAL
Posted
17 hours ago, BIGAL said:

1 need in code to find where the offset value is and override with an extra step at start of program pick 2 points to get offset distance. Maybe 

(/ (+ (vlax-curve-getDistatPoint e y) (vlax-curve-getDistAtPoint e x)) 2.)

 

2 may need 2 mods in the code there may be a RTOS function like (rtos x 2 2 ) the 1st 2 is decimal the second is number of decimal places, you can check a value and if its "18.1" force it to be "18.10" 

 

3 as I suggested in earlier post you need continuous plines not segments, then Lee's code will work. The program does not look for connecting objects.

 

4 Lee often comments here so he may respond to items 1 & 2.


Thank you for the explanation. Unfortunately, this is over my head because I know very little about coding haha!

Posted

Item 1 change the 2. to a value you want. 

 

Item 2 change (rtos d) to (rtos d 2 2 )

 

Item 3 make sure you have one pline covering full frontage of all intersecting lines.

Posted
On 30/08/2024 at 19:35, BIGAL said:

Item 1 change the 2. to a value you want. 

 

Item 2 change (rtos d) to (rtos d 2 2 )

 

Item 3 make sure you have one pline covering full frontage of all intersecting lines.


Thank you.

 

Item 1 didn't adjust where the text was place

 

Item 2 did work however!

Posted

You are right ignore Item 1 comment that is is mid point between 2 points.

 

If you want the text further inside the lots need to rework out the text position. Change the 1.1 or change the (* 1.1 ts) to a offset distance. eg 2.5 number only no brackets.

(vla-put-TextAlignmentPoint to (vlax-3D-point (polar m (+ ta (/ pi 2.)) (* 1.1 ts))))

(vla-put-TextAlignmentPoint to (vlax-3D-point (polar m (+ ta (/ pi 2.)) 2.5)))

 

 

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