Sambuddy Posted Tuesday at 07:42 PM Posted Tuesday at 07:42 PM (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 Tuesday at 07:43 PM by Sambuddy Quote
BIGAL Posted Tuesday at 10:35 PM Posted Tuesday at 10:35 PM 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 Tuesday at 11:48 PM Author Posted Tuesday at 11:48 PM 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 Wednesday at 03:49 AM Posted Wednesday at 03:49 AM 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 Wednesday at 07:06 AM Author Posted Wednesday at 07:06 AM Appreciate the input, I will give it a try. any ideas for the quest #2 @BIGAL ? Quote
Sambuddy Posted Wednesday at 01:12 PM Author Posted Wednesday at 01:12 PM 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 Wednesday at 10:53 PM Posted Wednesday at 10:53 PM 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.