Jump to content

Rotate, move attributes lisp


Astro

Recommended Posts

Hi all,

hope somebody can help me with this lisp.

 

I want to select one ore more blocks. Then the lisp scan the block for a list off attributes, TAG1" "TAG2" "TAG3".

And if the rotation angle is not 0 it rotates it to 0, and after give me the option to move the attributes.

 

 

 
(defun c:ROTATEMOVEATTRIBUTE1 (/ tag ss sel)
 (vl-load-com)
 (setq tag '("TAG1" "TAG2" "TAG3"))  ;; <<-- Tag to be Searched
 (and (setq ss (ssget '((0 . "INSERT") (66 . 1))))
      (vlax-for Obj (setq sel (vla-get-ActiveSelectionSet
                                (vla-get-ActiveDocument (vlax-get-acad-object))))
         (foreach att (append (vlax-invoke Obj 'GetAttributes)
                              (vlax-invoke Obj 'GetConstantAttributes))
           (if (vl-position (strcase (vla-get-TagString att)) tag)
             (vla-put-Rotation attVar 0
               (cond ((eq :vlax-true (vla-put-Rotation attVar 90)) :vlax-false)
                     (:vlax-true))))))
      (vla-delete sel))
 (princ))

Link to comment
Share on other sites

There's the rotate part corrected - its not just as simple as replacing visibilty properties with rotation... check the arguments needed for vla-put-rotation

 

(defun c:ROTATEMOVEATTRIBUTE1 (/ tag ss sel)
 (vl-load-com)
 (setq tag '("TAG1" "TAG2" "TAG3"))  ;; <<-- Tag to be Searched
 (and (setq ss (ssget '((0 . "INSERT") (66 . 1))))
      (vlax-for Obj (setq sel (vla-get-ActiveSelectionSet
                                (vla-get-ActiveDocument (vlax-get-acad-object))))
         (foreach att (append (vlax-invoke Obj 'GetAttributes)
                              (vlax-invoke Obj 'GetConstantAttributes))
           (if (vl-position (strcase (vla-get-TagString att)) tag)
             (vla-put-Rotation attVar 0))))
      (vla-delete sel))
 (princ))

Link to comment
Share on other sites

i think i got it :D

 

 
(defun c:ROTATEMOVEATTRIBUTE1( / ss obj)
 (vl-load-com)
 (setq tag '("TAG1" "TAG2" "TAG3"))
  (and (setq ss (ssget '((0 . "INSERT") (66 . 1))))
      (vlax-for obj (setq ss (vla-get-activeselectionset 
   (vla-get-activedocument (vlax-get-acad-object))))
   (if (= (vla-get-HasAttributes obj) :vlax-true)
     (foreach attVar (vlax-invoke obj 'GetAttributes)
       (if (not (= (vla-get-TagString attVar) tag))
         (vla-put-Rotation attVar 0)))))
     (vla-delete ss))
 (princ))

 

 

can sombody help me now with the move command.

I need to have the option to move the attributes after the rotation.

Link to comment
Share on other sites

Sorry my bad:

 

(defun c:ROTATEMOVEATTRIBUTE1 (/ tag ss sel)
 (vl-load-com)
 (setq tag '("TAG1" "TAG2" "TAG3"))  ;; <<-- Tag to be Searched
 (and (setq ss (ssget '((0 . "INSERT") (66 . 1))))
      (vlax-for Obj (setq sel (vla-get-ActiveSelectionSet
                                (vla-get-ActiveDocument (vlax-get-acad-object))))
         (foreach att (append (vlax-invoke Obj 'GetAttributes)
                              (vlax-invoke Obj 'GetConstantAttributes))
           (if (vl-position (strcase (vla-get-TagString att)) tag)
             (vla-put-Rotation att 0))))
      (vla-delete sel))
 (princ))

Link to comment
Share on other sites

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