I need assistance on automated dimensions

I need assistance on automated dimensions

NoelN.
Contributor Contributor
229 Views
1 Reply
Message 1 of 2

I need assistance on automated dimensions

NoelN.
Contributor
Contributor

My Question is there a way to automate the dimension process I uploaded the image for visualization. it pretty mush similar to DIMC command in autocad. I need an over all dimension and dimension every intersection selected. so the lisp will ask the user for a reference polyline(white) and give the option to select every intersection you want dimensioned. it will start with the first intersection select that the dimension will start(1) and end at "(7)" . the reason I want to automate because I have 200 plus sheet to dimension. Unless anybody has a better option or great idea, i'm open for suggestion. oh and also the lisp will use the same Dimstyle setting I have set. thank you so much in advance!

0 Likes
230 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

Answered this question years ago, pick 1st line, pick perp to second line and then dim all crossing lines. No idea what I called it. Will try to find again.

 

Found 1 not quite what you want. Will look for others.

 

 

 

; dim multi offsets
; By AlanH Nov 2021
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/line-up-dimension-text-in-multiple-dimensions/td-p/10739193

; (defun c:dimoffs ( / pt1 pt2 pt3 ent ent1  ss  obj1 obj2 tpos lst oldsnap oldaunits  )
(defun c:dimoffs ( /)

(if (not (tblsearch "dimstyle" "Standard"))
(alert "The correct dimstyle is not available \nResults may not be what is expected")
(command "dimstyle" "R" "Standard")
)

(setq oldsnap (getvar 'osmode))

; left or right by lee-mac
(defun lM:ISL-R (ent pnt /  cpt der )
		(setq pnt (trans pnt 1 0))
    (setq cpt (vlax-curve-getclosestpointto ent pnt)
          der (vlax-curve-getfirstderiv ent (vlax-curve-getparamatpoint ent cpt))
    )
    (if (minusp (sin (- (angle cpt pnt) (angle '(0.0 0.0) der))))
        (setq dir 1.0)
        (setq dir -1.0)
    )
    (princ)
)

(defun alg-ang (object pnt)
  (angle '(0. 0. 0.)
     (vlax-curve-getfirstderiv
       obj
       (vlax-curve-getparamatpoint
         object
         pnt
       )
     )
  )
)

(setq oldsnap (getvar 'osmode))
(setq oldaunits (getvar 'aunits))
(setvar 'aunits 3)

(setq pi2 (/ pi 2.0))

(setq ent (entsel "\nPick control line " ))
(setq entname (car ent))
(setq pt1 (cadr ent))
(setq pt1 (vlax-curve-getclosestpointto (vlax-ename->vla-object (car ent)) pt1))
(setq ent1 (entget (car ent)))

(setvar 'osmode 0)

(setq pt2 (getpoint "\nPick a point on left side"))
(setq  pt3 (getpoint pt2 "\nPick a point on right side "))

(setq ss (ssget "F" (list pt2 pt3)))

(setq ss (ssdel (cdr (assoc  -1 ent1))  ss)) ; remove control

(setq ang (angle pt2 pt3))

(setvar 'osmode 0)

(command "line" pt2 pt3 "")
(setq obj1 (vlax-ename->vla-object (entlast)))

(setq lst '() )
(repeat (setq x (sslength ss))
(setq entl (ssname ss (setq x (- x 1))))
(setq obj2 (vlax-ename->vla-object  (ssname ss  x)))
(setq intpt (vlax-invoke obj2 'intersectWith obj1 acExtendnone))
(LM:ISL-R (car ent) intpt)
(setq lst (cons (list  (* (distance  intpt pt1) dir) intpt entL) lst))
)

(setq lst (vl-sort lst '(lambda (x y) (< (car x)(car y)))))
(vla-delete obj1)

(setq  pt (cadr (nth 0 lst)))
(setq obj (vlax-ename->vla-object  ( caddr (nth 0 lst))))
(setq  ang (alg-ang obj pt))
(setq len (distance pt1 pt3))

(setq x -1)
(setq pt3 (polar pt1 (+ ang pi2) len))
(repeat (length lst) 
  (setq obj2 (vlax-ename->vla-object  (caddr (nth (setq x (1+ x)) lst))))
  (setq pt2 (vlax-curve-getclosestpointto obj2 pt1))
  (setq  dist  (distance pt1 pt2) )
  (if (< (car (nth  x  lst)) 0.0)(setq dist (- 0.0 dist)))
  (Command "Dim" "align" pt1 pt2 pt3   (rtos dist 2 2) "exit")
  (setq pt3 (polar pt3 ang 2.5))
  (setq obj2 (vlax-ename->vla-object (entlast)))
 (vlax-put obj2 'TextPosition pt3)
)

(setvar 'osmode oldsnap)
(setvar 'aunits oldaunits)

(princ)
)
(c:dimoffs)

 

 

 

Closer to what you want.

 

 

 

; dim multi offsets ver3
; By AlanH Jan 2022
; 

(defun c:dimoffs3 ( / )

(setq oldsnap (getvar 'osmode))
(setq oldaunits (getvar 'aunits))
(setvar 'aunits 3)

(setq pt1 (getpoint "\nPick a point on left side "))
(setq pt2 (getpoint pt1 "\nPick a point on other side of last line "))

(setvar 'dimse1 1)
(setvar 'dimse2 1)

(if (not (tblsearch "dimstyle" "Standard"))
(alert "The correct dimstyle is not available \nResults may not be what is expected")
(command "dimstyle" "R" "Standard")
)

(setvar 'osmode 0)

(setq ss (ssget "F" (list pt1 pt2)))

(command "line" pt1 pt2 "")
(setq obj1 (vlax-ename->vla-object (entlast)))

(setq lst '())
(repeat (setq x (sslength ss))
  (setq obj2 (vlax-ename->vla-object (ssname ss (setq x (1- x)))))
   (setq intpt (vlax-curve-getclosestpointto obj2 pt1))
  (setq lst (cons (list (distance intpt pt1) intpt) lst))
)

(setq lst (vl-sort lst '(lambda (x y) (< (car x)(car y)))))
(vla-delete obj1)

(setq ang (angle pt1 (nth 1 (nth 0 lst))))
(setq len (distance pt1 pt3))

(setq x 0)
(repeat (- (length lst) 1)
   (Command "Dim" "align" (cadr (nth x lst)) (cadr (nth (1+ x) lst)) (cadr (nth x lst)) "" "exit")
   (setq x (1+ x))
)

(setvar 'osmode oldsnap)
(setvar 'aunits oldaunits)
(setvar 'dimse1 0)
(setvar 'dimse2 0)

(princ)
)
(c:dimoffs3)

 

Just drag a line over all the desired lines pt1 -> pt2.

 

 

0 Likes