Jump to content

Attribute rotation in dynamic block


JeepMaster

Recommended Posts

We use this light switch block for work. For the life of me, I can't figure out how to make the attribute to stay (LOCKED) at rotation 0 when inserting no matter which angle the swtich is inserted. The only way the text stays at rotation 0 is if I insert the block as is (pointing right), then align the switch to a wall. The block is created with alignment grip. So if I add the switch to a wall at an angle (eg:45 degrees), the text will be rotated and stay rotated. If I insert the switch on the left side of the wall, the attributes will be upside down. I can manually rotate the attributes back to 0 degrees and it will stay locked to 0 degrees. But what I want it to do is to be inserted at 0 degrees to begin with. Can this be done?

Switch.dwg

Link to comment
Share on other sites

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • JeepMaster

    7

  • neekcotrack

    5

  • dbroada

    3

  • jcparms

    2

the only way I was able to sort this out was to setup different view states i.e. 90,180,270 and 380 and with each state the attribute was set to 0. In effect the block rotates but the att stays local. alternatively you could set the main part of your block to a rotation grip..

let me know if you manage to come up with a better solution.

Link to comment
Share on other sites

the only way I was able to sort this out was to setup different view states i.e. 90,180,270 and 380 and with each state the attribute was set to 0. In effect the block rotates but the att stays local. alternatively you could set the main part of your block to a rotation grip..

let me know if you manage to come up with a better solution.

Ozy, my block has a rotation grip already. Do you mean adding another one for the attributes? So far, this block is the best I can do with minimal inputs. Drop the block to a floor plan while aligning to a wall, then change the attribute angle to zero manually. By now the attribute angle will stay locked to zero. Then copy as much switches as I need from it without rotation, then use the rotation grip on each block to rotate to match walls. Will lisp work on this? Somehow set rotation to zero and then insert block?!?

Link to comment
Share on other sites

  • 5 weeks later...
the only way I was able to sort this out was to setup different view states i.e. 90,180,270 and 380 and with each state the attribute was set to 0. In effect the block rotates but the att stays local. alternatively you could set the main part of your block to a rotation grip..

let me know if you manage to come up with a better solution.

My friend help me out and wrote a reactor lisp. Once the reactor lisp is activated, everytime I use a symbol from the toolpalette, it will set all the attributes to 0 degrees. Commands are "ROT0" and "SROT0". Here's the code:

(defun Attributs_ini(Rea Cde)
 (setq dernier_ent (entlast))
)
(defun Attributs_rot_0(Rea Cde / bl js i n)
 (cond
   ((eq (car Cde) "EXECUTETOOL")
     (setq js (ssget "_L"))
   )
   ((eq (car Cde) "ROTATE")
     (setq js (ssget "_p"))
   )
   ((eq (car Cde) "MIRROR")
     (setq js (ssget "_p"))
   )
   ((eq (car Cde) "GRIP_ROTATE")
     (setq js (cadr (ssgetfirst)))
   )
   ((eq (car Cde) "GRIP_MIROR")
     (setq js (cadr (ssgetfirst)))
   )
;    ((eq (car Cde) "INSERT")
;      (setq js (ssadd))
;      (ssadd (entlast) js)
;    )
;    ((eq (car Cde) "COPY")
;      (setq js (ssadd) n (entnext dernier_ent))
;      (while n
;        (ssadd n js)
;        (setq n (entnext n))
;      )
;    )
;    ((eq (car Cde) "UCS")
;      (setq js (ssget "x" (list (cons 0 "INSERT"))))
;    )
 )
 (if js
   (progn
     (setq n 0)
     (while (ssname js n)
       (setq bl (entget (ssname js n)))
       (if (eq (cdr (assoc 0 bl)) "INSERT")
         (if (cdr (assoc 66 bl))
           (progn
             (while (not (eq (cdr (assoc 0 bl)) "SEQEND"))
               (if (eq (cdr (assoc 0 bl)) "ATTRIB")
                 (progn
                   (setq bl (subst (cons 50 0) (assoc 50 bl) bl))
                   (entmod bl)
                   (entupd (cdr (assoc -1 bl)))
                 )
               )
               (setq bl (entget (entnext (cdr (assoc -1 bl)))))
             )
           )
         )
       )
       (setq n (1+ n))
     )
   )
 )
 (princ)
)
(defun c:srot0(/ i j n)
 (if (setq i (vlr-reactors :vlr-Command-Reactor))
   (progn
     (setq n 1 i (nth n (car i)))
     (while i
       (setq j nil)
       (if (or (eq (cdr (car (vlr-reactions i))) 'ATTRIBUTS_ROT_0) (eq (cdr (car (vlr-reactions i))) 'ATTRIBUTS_INI))
         (setq j i)
       )
       (if j
         (vlr-remove j)
         (setq n (1+ n))
       )
       (if (setq i (vlr-reactors :vlr-Command-Reactor))
         (setq i (nth n (car i)))
       )
     )
     (if mrea_rot0
       (princ "\n\tDisable angle 0 of the Attributes")
     )
     (setq mrea_rot nil)
   )
 )
 (princ)
)
(defun c:rot0()
 (if (not mrea_rot0)
   (progn
     (c:srot0)
     (vlr-command-reactor nil '((:vlr-commandwillstart . Attributs_ini)))
     (setq mrea_rot0 (vlr-command-reactor nil '((:vlr-commandEnded . Attributs_rot_0))))
     (princ "\n\tEnable angle 0 of the Attributes")
   )
   (princ "\n\tAngle 0 of the Attributes is ready")
 )
 (princ)
)
(vl-load-com)
(princ (strcat "\n\tFor enable angle 0 of the Attributes, command ROT0.\n\tfor backward, command SROT0."))
(princ)

Link to comment
Share on other sites

  • 5 months later...

I am also having the same problem and my boss wants me to write a lsp program to do the same as the RO (ROTATE) command but in addition rotate the attributes to 0 degrees. If any one has any answers let me know. I am using predefined blocks with attributes and not using the tool palette

Link to comment
Share on other sites

You can also you diesel macro to do this also. If you like you can put it into a lisp to do the same.

I'm not familiar with diesel macro. Can you explain further?

Link to comment
Share on other sites

Ok diesel macros are more used for tool palettes but are also used in lisp command to. If you attach a block that you are using I can look at it and make you a lisp that will ask you to pick what to rotate, then let you rotate it and last change your attrabute text back to 0.

Link to comment
Share on other sites

If you use the flyout Tool Pallete Buttons you will find it is easier to get the attributes to stay at 0 no matter what angle it is. You will see in the command string area this something that looks weird. That would be diesel macro it is one of autocads easier code to use. If still interested let me know.

Link to comment
Share on other sites

Thanks dbroada, but I don't have a problem making the block to do the "fairest wheel" thing on the attribute. I only need to be able to insert the block at any angle from the toolpalette while the attribute stays locked to zero rotation.

 

neekcotrack, will you please be so kind to show me how to use it on diesel macro to do this. My example switch block is still on the first post.:)

Link to comment
Share on other sites

Ok try the block that I attach and make your code like I have below In the command string of the tool pallete button properties. Just make sure add another search path under option to be going to where you put the block!

 

-I;sw_1;s;(getvar "dimscale");\\-attedit;;;;;l;;a;0;;

 

Tell me if this is what you are looking for?

Link to comment
Share on other sites

Ok try the block that I attach and make your code like I have below In the command string of the tool pallete button properties. Just make sure add another search path under option to be going to where you put the block!

 

-I;sw_1;s;(getvar "dimscale");\\-attedit;;;;;l;;a;0;;

 

Tell me if this is what you are looking for?

It seems like the block is different. I need to use our company standard dynamic blocks like the one I posted.:(

Link to comment
Share on other sites

  • 4 years later...

After a few days of trying to do this myself, looking online for answers, and not wanting to use a lisp; I've figured out an answer. Although I have not tested it extensively, it seems to work.

 

1. Assemble your block, and place the Parameters like you would normally.

2. Place a Point Parameter at the middle of your text (I have my text justified at middle).

3. Associate a Move Action to that point, and only include the text.

4. Add the other Actions you want. When making your Rotation Action, do so so it does not include the text from the Action, but does include the Move Parameter and Grip associated to the text.

5. Select the Move Action associated with your text. In the Properties, change the Number of Grips to 0, and set Chain Actions to "yes".

 

This SHOULD work. Like I said, I haven't tested real complex blocks yet. Hope it helps some people out!

Edited by jcparms
Excess words... Misspelling...
Link to comment
Share on other sites

This SHOULD work. Like I said, I haven't tested real complex blocks yet. Hope it helps some people out!
it does work - that method was put forwards by me in post 11 of this thread
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...