Jump to content

Recommended Posts

Posted (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...

image.png.54dacc4bff699d2e4544c8e76f35f079.png

 

After...

image.png.70fa394e483595598f4a253a0345695b.png

my wish...

image.png.cd8605a865b7ae0fc764525dacd7484d.png

 

 

 

Edited by Sambuddy
Posted

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.

Posted

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.

Posted

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

 

Posted

Appreciate the input, I will give it a try.

any ideas for the quest #2 @BIGAL ?

Posted

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

 

Posted

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.

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...