Nikon Posted April 11 Posted April 11 This code works well with static blocks, but when working with dynamic blocks, the frame shift to the left. Is there any way to fix this? Or do need separate code for dynamic blocks? Thank you in advance... ;;; Creating a rectangle around the perimeter of a selected rectangular object (defun c:ObjBoundary (/ obj objType vla-obj pt1 pt2 minPoint maxPoint pline) (princ "\nSelect object: ") (if (setq obj (entsel)) (progn (setq obj (car obj)) (setq objType (cdr (assoc 0 (entget obj)))) (princ (strcat "\nThe object type is selected: " objType)) (setq vla-obj (vlax-ename->vla-object obj)) (setq pt1 (vlax-make-safearray vlax-vbDouble '(0 . 2))) (setq pt2 (vlax-make-safearray vlax-vbDouble '(0 . 2))) (vla-GetBoundingBox vla-obj 'pt1 'pt2) (setq minPoint (list (vlax-safearray-get-element pt1 0) (vlax-safearray-get-element pt1 1) (vlax-safearray-get-element pt1 2) ) maxPoint (list (vlax-safearray-get-element pt2 0) (vlax-safearray-get-element pt2 1) (vlax-safearray-get-element pt2 2) ) ) (setq pline (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 4) '(70 . 1) (cons 10 (list (car minPoint) (cadr minPoint) 0.0)) (cons 10 (list (car maxPoint) (cadr minPoint) 0.0)) (cons 10 (list (car maxPoint) (cadr maxPoint) 0.0)) (cons 10 (list (car minPoint) (cadr maxPoint) 0.0)) ) )) (princ "\nThe perimeter of the object is created as a polyline.") (princ) ) (princ "\nThe object is not selected.") ) (princ) ) (vl-load-com) (princ "\nThe perimeter of the object - enter the command Object Boundary to run.") (princ) Quote
GLAVCVS Posted April 11 Posted April 11 Hi Nikon Blocks are scarce in my diet. But if you add any of those disobedient blocks , maybe I can help you. 1 Quote
Nikon Posted April 11 Author Posted April 11 (edited) On 4/11/2025 at 4:27 PM, GLAVCVS said: Hi Nikon Blocks are scarce in my diet. But if you add any of those disobedient blocks , maybe I can help you. Expand Hi @GLAVCVS The blocks are obedient, but the bounding box is disobedient... OBJBOUNDARY.dwgFetching info... Edited April 11 by Nikon Quote
GLAVCVS Posted April 11 Posted April 11 There are a couple of 'ATTDEF' objects with the 'VISIBLE' property disabled. Quote
GLAVCVS Posted April 11 Posted April 11 (edited) Use this to see for yourself (defun c:todovis (/ cj n ent lstent) (if (setq cj (ssget "x" '((60 . 1)))) (while (setq ent (ssname cj (setq n (if n (1+ n) 0)))) (entmod (append (entget ent) (list '(60 . 0)))) ) ) (princ) ) Edited April 11 by GLAVCVS 1 Quote
GLAVCVS Posted April 11 Posted April 11 I guess you should just move those attributes a little to the right and make them invisible again. 1 Quote
Nikon Posted April 11 Author Posted April 11 (edited) On 4/11/2025 at 8:51 PM, GLAVCVS said: (defun c:todovis (/ cj n ent lstent) (if (setq cj (ssget "x" '((60 . 1)))) (while (setq ent (ssname cj (setq n (if n (1+ n) 0)))) (setq lstent (append (setq lstent (entget ent)) (list '(60 . 0))) n (+ n 1) ) (entmod lstent) ) ) (princ) ) Expand What a good code! Thanks! Is it possible to configure the creation of a frame for dynamic blocks with attributes that go beyond the block? Is it possible to ignore this in the code so that attributes are not taken into account when creating the frame? Edited April 11 by Nikon Quote
Nikon Posted April 11 Author Posted April 11 (edited) On 4/11/2025 at 8:58 PM, GLAVCVS said: I guess you should just move those attributes a little to the right and make them invisible again. Expand If the attributes are inside the block, then the frame is created correctly. Do I always need to check for hidden attributes? It's a little uncomfortable... Edited April 11 by Nikon Quote
GLAVCVS Posted April 11 Posted April 11 No Simply modifying the matrix blocks will solve the problem. If no one can do it on your own, or if no one has done it before, then I'll help you do it tomorrow. 1 Quote
GLAVCVS Posted April 12 Posted April 12 (edited) Hi Try this (defun c:makeBlockObedient (/ conj it n e le) (princ "\nSelect block to analyze...") (if (setq conj (ssget '((0 . "INSERT")))) (while (setq it (ssname conj (setq n (if n (1+ n) 0)))) (while (/= (cdr (assoc 0 (setq le (entget (setq e (entnext (if e e it))))))) "SEQEND") (if (assoc 60 le) (if (setq p (getpoint (cdr (assoc 10 le)) "\nInvisible attribute detected: Indicates its new position (RIGHT CLICK to skip)...? ")) (vla-move (vlax-ename->vla-object e) (vlax-3d-point (cdr (assoc 10 le))) (vlax-3d-point p)) ) ) ) ) ) (princ) ) Edited April 12 by GLAVCVS 1 Quote
Nikon Posted April 12 Author Posted April 12 (edited) On 4/12/2025 at 5:53 PM, GLAVCVS said: "\nInvisible attribute detected: Indicates its new position (RIGHT CLICK to skip)...? ")) Expand Hi @GLAVCVS thanks! This code makes the block Obedient. Muchas gracias! Es super! Te debo otra taza de cafe... Edited April 12 by Nikon 1 Quote
Stefan BMR Posted April 12 Posted April 12 Hi Nikon Isn't more easy, in your case, to get the insertion point as the lower-left corner, and for the top-right corner just add the width, height? Multiplied with the scale, if necessary. Quote
Nikon Posted April 13 Author Posted April 13 (edited) On 4/12/2025 at 7:05 PM, Stefan BMR said: Isn't more easy, in your case, to get the insertion point as the lower-left corner, and for the top-right corner just add the width, height? Multiplied with the scale, if necessary. Expand Lisp ObjBoundary involves creating frames for different objects (not just blocks), so the insertion point should not be taken into account here (imho)... The insertion points can be in different places, the borders should not depend on them.... Edited April 13 by Nikon Quote
GLAVCVS Posted April 13 Posted April 13 On 4/12/2025 at 7:05 PM, Stefan BMR said: Hola Nikon ¿No serÃa más fácil, en tu caso, colocar el punto de inserción en la esquina inferior izquierda y, para la esquina superior derecha, simplemente sumar el ancho y la altura? Multiplicado por la escala, si es necesario. Expand @Stefan BMR Simply, after running 'makeBlockObedient' for each block that needs it, copy the modified instance and paste it into a new drawing that will serve as a template in the future. 1 Quote
GLAVCVS Posted April 13 Posted April 13 Obviously, any new instance of that block created in that template will retain the necessary modifications so that the problem does not occur again. 1 Quote
Nikon Posted April 13 Author Posted April 13 (edited) On 4/13/2025 at 7:24 AM, GLAVCVS said: Obviously, any new instance of that block created in that template will retain the necessary modifications so that the problem does not occur again. Expand Initially, I just wanted the creation of borders in the code ObjBoundary to be independent of the location of hidden or visible block attributes... Edited April 13 by Nikon Quote
ronjonp Posted April 15 Posted April 15 @Nikon You could use Lee's minimum bounding box code and iterate your titleblock elements removing items that do not plot or are not visible. 1 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.