Sambuddy Posted December 17, 2024 Posted December 17, 2024 (edited) The current routine works but requires 2 major changes (1) and (2). So... basically what I would like to accomplish would be: 1) find a way so that the filtering process accounts for a specific block throughout the drawing instead of :L , but no success on this regard: (if (setq s (ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "`*U*,POTEAUX_PLAN_BLK1")))) (repeat (setq i (sslength s)) (setq o (vlax-ename->vla-object (setq ent (ssname s (setq i (1- i)))))) (if (and (vlax-property-available-p o 'effectivename) (= "poteaux_plan_blk1" (strcase (vla-get-effectivename o) t)) ) (progn ... It works as is, but cannot find a way to incorporate (2 . "`*U*,POTEAUX_PLAN_BLK1") for the dynamic block "POTEAUX_PLAN_BLK1". So I ended up selecting the blocks one by one as an alternative. 2) The attributes on the block are arranged in the same manner as displayed on the tags list. Is it possible to move tags downward by say 2.5 units to re-arrange the position after tags are removed (Photo before & after)? (defun c:foo (/ s tags) ;; List of tags to target (setq tags '( "ENDOMAGÉ" "FISSURÉ" "BANDEJAUNE" "COUPÉ" "TRANSFERT" "<1M" "<3M" "INC.+5" ) ) ;; Select attributed blocks (if (setq s (ssget ":L" '((0 . "INSERT") (66 . 1)))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) ; Loop through selected entities (foreach tag tags (if (vl-catch-all-error-p (vl-catch-all-apply (function (lambda () ;; Get the current value of the attribute (cond ;; Case 1: Empty or "NON" -> Set value to "" ((or (eq "" (getpropertyvalue e tag)) (eq "NON" (strcase (getpropertyvalue e tag)))) (setpropertyvalue e tag "")) ;; Case 2: "OUI" -> Set value to the tag name ((eq "OUI" (strcase (getpropertyvalue e tag))) (setpropertyvalue e tag tag)) ) ) ) ) ) (princ (strcat "\nError handling tag: " tag)) ; Error Handling );end if ) ) ); end if (princ) ); end defun Any help is appropriated! Before... After... my wish... Edited December 17, 2024 by Sambuddy Quote
BIGAL Posted December 17, 2024 Posted December 17, 2024 The problem may be as simple as check what 'effective name returns in terms of string case, you are checking a lower case answer. If using strcase try everything as capitals. Remember the alphabet has 52 characters. Quote
Sambuddy Posted December 17, 2024 Author Posted December 17, 2024 Block name is returned as all capital and matches my block name. I also do not think that my approach is incorrect on the first question I posed. Quote
BIGAL Posted December 18, 2024 Posted December 18, 2024 I may be wrong but every block has an effective name, so maybe just try this. Note the removal of T and check "has effective" (if (= "POTEAUX_PLAN_BLK1" (strcase (vla-get-effectivename o))) (progn Quote
Sambuddy Posted December 18, 2024 Author Posted December 18, 2024 Appreciate the input, I will give it a try. any ideas for the quest #2 @BIGAL ? Quote
Sambuddy Posted December 18, 2024 Author Posted December 18, 2024 My first question is resolved regarding selection/ filtering, thanks to @BIGAL. Can someone please help with #2, or throw me some ideas based on what I described on the original post with photos? (defun c:foo (/ s tags) ;; List of tags to target (setq tags '( "ENDOMAGÉ" "FISSURÉ" "BANDEJAUNE" "COUPÉ" "TRANSFERT" "<1M" "<3M" "INC.+5" ) ) ;; Select attributed blocks (if (setq s (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," "POTEAUX_PLAN_BLK1"))))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) ; Loop through selected entities (foreach tag tags (if (vl-catch-all-error-p (vl-catch-all-apply (function (lambda () ;; Get the current value of the attribute (cond ;; Case 1: Empty or "NON" -> Set value to "" ((or (eq "" (getpropertyvalue e tag)) (eq "NON" (strcase (getpropertyvalue e tag)))) (setpropertyvalue e tag "")) ;; Case 2: "OUI" -> Set value to the tag name ((eq "OUI" (strcase (getpropertyvalue e tag))) (setpropertyvalue e tag tag)) ) ) ) ) ) (princ (strcat "\nError handling tag: " tag)) ; Error Handling );end if ) ) ); end if (princ) ); end defun Quote
BIGAL Posted December 18, 2024 Posted December 18, 2024 If it's for one block you can get at the attribute position so maybe move all the attributes into a new Y position. Looking into an attribute InsertionPoint = (693.8875 56.125 0.0), I thought could move pretty sure have done before will test some more. 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.