MikeP Posted June 11, 2009 Posted June 11, 2009 I have this code, but I cant seem make it do that the surrounding box does not get drawn. I want it to prompt me to show the box or now, but what it does that I dont like it, if i select "no" do not draw box, it still makes the box, but only on a hidden layer. I want it to not create a box at all if i say no. Can you please help me out. ;;;==== (defun multiple_enclosing_rectangle ( / active_document active_selectionset list_of_x_pt1 list_of_y_pt1 list_of_x_pt2 list_of_y_pt2 pt_1 pt_2 pt_3 pt_4 pt_txt_x pt_txt_y space sset vertices_list x_min x_max y_min y_max hide ) (setq active_document (vla-get-activedocument (vlax-get-acad-object) ) ) (setq sset (ssget)) (setq active_selectionset (vla-get-activeselectionset active_document) ) (vlax-for item active_selectionset (vlax-invoke-method item 'GetBoundingBox 'pt1 'pt2 ) (setq list_of_x_pt1 (cons (car (vlax-safearray->list pt1)) list_of_x_pt1 ) ) (setq list_of_y_pt1 (cons (cadr (vlax-safearray->list pt1)) list_of_y_pt1 ) ) (setq list_of_x_pt2 (cons (car (vlax-safearray->list pt2)) list_of_x_pt2 ) ) (setq list_of_y_pt2 (cons (cadr (vlax-safearray->list pt2)) list_of_y_pt2 ) ) ) (setq x_min (apply 'min list_of_x_pt1)) (setq y_min (apply 'min list_of_y_pt1)) (setq x_max (apply 'max list_of_x_pt2)) (setq y_max (apply 'max list_of_y_pt2)) (setq pt_1 (list x_min y_min 0.0)) (setq pt_2 (list x_max y_max 0.0)) (setq pt_3 (list (car pt_2)(cadr pt_1) 0.0)) (setq pt_4 (list (car pt_1)(cadr pt_2) 0.0)) (setq vertices_list (apply 'append (list pt_1 pt_3 pt_2 pt_4 pt_1) ) ) (command "-layer" "m" "Dim" "c" "red" "" "lt" "continuous" "dim" "") (vla-addpolyline (setq space (vlax-get active_document (if (equal (getvar "cvport") 1) 'PaperSpace 'ModelSpace ) ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length vertices_list) 1)) ) vertices_list ) ) ) (setq pt_txt_x (mapcar '+ '(0.0 3.5 0.0) (mapcar '* '(0.5 0.5 0.5) (mapcar '+ pt_4 pt_2))) ) (setq pt_txt_y (mapcar '+ '(-3.5 0.0 0.0) (mapcar '* '(0.5 0.5 0.5) (mapcar '+ pt_4 pt_1))) ) (command "-layer" "m" "0" "") (vla-AddDimAligned space (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_4) 1)) ) pt_4 ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_2) 1)) ) pt_2 ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_txt_x) 1)) ) pt_txt_x ) ) ) (vla-AddDimAligned space (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_4) 1)) ) pt_4 ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_1) 1)) ) pt_1 ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_txt_y) 1)) ) pt_txt_y ) ) ) ;(command "-layer" "s" "Dim" "off" "Dim" "y" "") ;(command "-layer" "s" "Dim" "off" "Dim" "") ;(command "-layer" "s" "Dim" "off" "Dim" "") (command "-layer" "m" "0" "c" "" "lt" "continuous" "0" "") (initget "Yes No") (if (/= "No" (getkword "\nHide Box? [Yes/No] ? <Y>: ")) (command "_.LAYER" "s" "Dim" "_Off" "Dim" "_Y" "")) (princ) ) ;;;===================================================== (defun c:mer()(multiple_enclosing_rectangle)(princ)) ;;;===================================================== (prompt "\n*** Type MER to run the program ***") ;;;======================== Quote
Lee Mac Posted June 11, 2009 Posted June 11, 2009 Maybe I'm missing something, but surely, if you didn't want it to make the box, you wouldn't invoke the command in the first place? Quote
MikeP Posted June 11, 2009 Author Posted June 11, 2009 Maybe I'm missing something, but surely, if you didn't want it to make the box, you wouldn't invoke the command in the first place? I want it make the box, if I prompt yes. but if I prompt no, then I want no box created, rather than one that is placed on a hidden layer. Quote
Lee Mac Posted June 11, 2009 Posted June 11, 2009 As a quick fix: ;;;==== (defun multiple_enclosing_rectangle ( / active_document active_selectionset list_of_x_pt1 list_of_y_pt1 list_of_x_pt2 list_of_y_pt2 pt_1 pt_2 pt_3 pt_4 pt_txt_x pt_txt_y space sset vertices_list x_min x_max y_min y_max hide ) (setq active_document (vla-get-activedocument (vlax-get-acad-object) ) ) (setq sset (ssget)) (setq active_selectionset (vla-get-activeselectionset active_document) ) (vlax-for item active_selectionset (vlax-invoke-method item 'GetBoundingBox 'pt1 'pt2 ) (setq list_of_x_pt1 (cons (car (vlax-safearray->list pt1)) list_of_x_pt1 ) ) (setq list_of_y_pt1 (cons (cadr (vlax-safearray->list pt1)) list_of_y_pt1 ) ) (setq list_of_x_pt2 (cons (car (vlax-safearray->list pt2)) list_of_x_pt2 ) ) (setq list_of_y_pt2 (cons (cadr (vlax-safearray->list pt2)) list_of_y_pt2 ) ) ) (setq x_min (apply 'min list_of_x_pt1)) (setq y_min (apply 'min list_of_y_pt1)) (setq x_max (apply 'max list_of_x_pt2)) (setq y_max (apply 'max list_of_y_pt2)) (setq pt_1 (list x_min y_min 0.0)) (setq pt_2 (list x_max y_max 0.0)) (setq pt_3 (list (car pt_2)(cadr pt_1) 0.0)) (setq pt_4 (list (car pt_1)(cadr pt_2) 0.0)) (setq vertices_list (apply 'append (list pt_1 pt_3 pt_2 pt_4 pt_1) ) ) (command "-layer" "m" "Dim" "c" "red" "" "lt" "continuous" "dim" "") (setq poly (vla-addpolyline (setq space (vlax-get active_document (if (equal (getvar "cvport") 1) 'PaperSpace 'ModelSpace ) ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length vertices_list) 1)) ) vertices_list ) ) )) (setq pt_txt_x (mapcar '+ '(0.0 3.5 0.0) (mapcar '* '(0.5 0.5 0.5) (mapcar '+ pt_4 pt_2))) ) (setq pt_txt_y (mapcar '+ '(-3.5 0.0 0.0) (mapcar '* '(0.5 0.5 0.5) (mapcar '+ pt_4 pt_1))) ) (setvar "CLAYER" "0") (setq Dim1 (vla-AddDimAligned space (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_4) 1)) ) pt_4 ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_2) 1)) ) pt_2 ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_txt_x) 1)) ) pt_txt_x ) ) )) (setq Dim2 (vla-AddDimAligned space (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_4) 1)) ) pt_4 ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_1) 1)) ) pt_1 ) ) (vlax-make-variant (vlax-safearray-fill (vlax-make-safearray vlax-vbdouble (cons 0 (- (length pt_txt_y) 1)) ) pt_txt_y ) ) )) ;(command "-layer" "s" "Dim" "off" "Dim" "y" "") ;(command "-layer" "s" "Dim" "off" "Dim" "") ;(command "-layer" "s" "Dim" "off" "Dim" "") (command "-layer" "m" "0" "c" "" "lt" "continuous" "0" "") (initget "Yes No") (if (= "Yes" (getkword "\nErase Box? [Yes/No] ? <N>: ")) (mapcar 'vla-delete (list Dim1 Dim2 Poly))) (princ) ) ;;;===================================================== (defun c:mer()(multiple_enclosing_rectangle)(princ)) ;;;===================================================== (prompt "\n*** Type MER to run the program ***") ;;;======================== Quote
MikeP Posted June 11, 2009 Author Posted June 11, 2009 you have it erasing the dims as well as the box. id like to keep the dimensions Quote
MikeP Posted June 11, 2009 Author Posted June 11, 2009 you have it erasing the dims as well as the box. id like to keep the dimensions never mind I fixed it:D Quote
MikeP Posted June 11, 2009 Author Posted June 11, 2009 how can it be so that I can use command from a side view to dimension 3d objects? Quote
Lee Mac Posted June 11, 2009 Posted June 11, 2009 You would have to use "TRANS" to convert all the relevant points. Quote
MikeP Posted June 12, 2009 Author Posted June 12, 2009 You would have to use "TRANS" to convert all the relevant points. Trans????? Quote
Lee Mac Posted June 12, 2009 Posted June 12, 2009 Trans????? Yes, trans is an AutoLISP function that will convert a point to a different UCS. Quote
Recommended Posts
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.