Autodimension Max Height and Width

Autodimension Max Height and Width

Anonymous
Not applicable
1,279 Views
4 Replies
Message 1 of 5

Autodimension Max Height and Width

Anonymous
Not applicable

Hi all,

I am looking for a lisp to autodimension the maximum height and width of a sheet metal flat patern polyline. It is hard for me to code from scratch but i am posting this thinking someone may have encountered the same problem and lisp is hidden somewhere.

 

See attached image showing what i am trying to achive.

 

0 Likes
Accepted solutions (1)
1,280 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant
Accepted solution

Hi, try this routine:

 

Spoiler
;; Selection Set Bounding Box  -  Lee Mac
;; Returns a list of the lower-left and upper-right WCS coordinates of a
;; rectangular frame bounding all objects in a supplied selection set.
;; s - [sel] Selection set for which to return bounding box

(defun LM:ssboundingbox ( s / a b i m n o )
    (repeat (setq i (sslength s))
        (if
            (and
                (setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))))
                (vlax-method-applicable-p o 'getboundingbox)
                (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-getboundingbox (list o 'a 'b))))
            )
            (setq m (cons (vlax-safearray->list a) m)
                  n (cons (vlax-safearray->list b) n)
            )
        )
    )
    (if (and m n)
        (mapcar '(lambda ( a b ) (apply 'mapcar (cons a b))) '(min max) (list m n))
    )
)


(defun c:DimMax ( / b s )
    (if (and (setq s (ssget))
	     (setq b (LM:ssboundingbox s))
	     )
      (command "_.DIMLINEAR"
	       "_none" (car b)
	       "_none" (list (caadr b) (cadar b))
	       "_none" "@0,-2"
	       "_.DIMLINEAR"
	       "_none" (list (caadr b) (cadar b))
	       "_none" (cadr b)
	       "_none" "@2,0"
	       ))
  (princ)
)

(vl-load-com)

...where were used Lee Mac's Selection Set Bounding Box funtion

 

Next time pls post the DWG sample! We don't know if you used polyline, or lines, what units you're using... 

0 Likes
Message 3 of 5

Anonymous
Not applicable

BeekeeCZ

The Lisp works Great. 

Using Polyline and Units are inches and it also adapts the standard dimension style. 

Thanks a ton.

 

0 Likes
Message 4 of 5

danglar
Advocate
Advocate

Is it possible to save values of these dimmensions in output file?

0 Likes
Message 5 of 5

danglar
Advocate
Advocate

I tried to solve a problem of publishing a real paper sizes of layouts using dimensions of MIN MAX boundary points of selected objects in each layout by combining some functions founded here. Now I have a routine can do it (see attached Real Paper Size For All Layouts - REA.lsp) but I want to publish it in a table form

Is it possible to do it in this way?

Any help or suggestions will be very appreciated

0 Likes