Jump to content

Script


mapman1

Recommended Posts

First time scripting........

I have an attributed block, (two attributes, floating). The attributes are on their own layers. The block can be any desired rotation. The

attributes need to be (0) rotation for ease of reading. I am trying to

use -attedit in a script to rotate all attributes back to zero without

losing existing data in the various tag fields and without changing the

existing rotation value of the block. When the script gets to where it

needs to select all the objects...........the script stops. Select is where I have the problem. Help would be appreciated. See below.

 

;repetitive attribute editing

;command

-attedit

;edit attributes one at a time?

Y

;enter block name

Hydrant_4inch

;enter attribute tag

HN4IN

;enter attribute value

*

;select objects

select

Previous

;enter an option (Angle)

A

;enter a value (zero rotation)

0

;enter an option (Next)

N

Link to comment
Share on other sites

Make sure this lisp is loaded...then all you have to do is add the lines below to your script:

 

(defun attstozerorotation (blockname / e ss)
 (vl-load-com)
 (if (setq ss (ssget "_x" (list (cons 0 "INSERT") (cons 2 blockname))))
   (while (setq e (ssname ss 0))
     (foreach att (vlax-invoke (vlax-ename->vla-object e) 'getattributes)
       (vl-catch-all-apply 'vlax-put (list att 'rotation 0.0))
     )
     (ssdel e ss)
   )
 )
 (princ)
)
;;Lines to add to script...use your block names
;;one block
(attstozerorotation "blockname")
;;many blocks
(mapcar 'attstozerorotation '("blockname1" "blockname2" "blockname3"))

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