Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How not to rotate Attributes

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
AMC663
647 Views, 9 Replies

How not to rotate Attributes

Hi All,

 

I have this snippet that inserts a block “Exit_Arrow”.  The block has one attribute.
Is it possible to force the attribute to remain at “0” rotation regardless what angle the bock is rotated?

 

(defun C:Exit_Arrow (/ LA DS)
(setq LA (getvar "clayer"))
(setq DS (getvar "dimscale"))
(C:TTEXT)
(command "._insert" " Exit_Arrow " pause DS "")
(setvar "clayer" LA)
(princ))

 

Is it possible to create blocks whose attributes remain at "0" rotation regardless the host block's rotation?

 

Thank you in advance,

 

G.S.

9 REPLIES 9
Message 2 of 10
scot-65
in reply to: AMC663

You are in luck today.

The following was found on this board some time ago.

However, you will have to tailor this to your liking

(entlast or entnext in lieu of ssget).

 

Looking at your code, one will have to do some user checking

to see if the arrowhead was indeed inserted (and not canceled)

before the attached code is executed.

 

Good Luck!

 


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 3 of 10
AMC663
in reply to: scot-65

Hi Scot,

First of all thank you very much.

Forgive my ignorance, but how do I marry the two codes to keep the attribute from rotating DURING insertion.

Your code is much better than what I have.  Yours rotates attributes in all selected blocks, not in just one.

 Thank you,

 GS

Message 4 of 10
alanjt_
in reply to: AMC663
Message 5 of 10
AMC663
in reply to: scot-65

Scot,

 

Your code is a big help in uprighting all attributes at once.  Really handy!

 

Thank again,

 

GS

 

 

Message 6 of 10
AMC663
in reply to: alanjt_

Alen,

 

I just got through the link.  Very good information and I'll have to go through it.

 

Thank you very much,

 

GS

Message 7 of 10
scot-65
in reply to: AMC663

Did you get it figured out?

I did not have a snippet that fit your request, but rather one that

can be reworked to do as you requested.

If you still need some help merging, send me a private message

and, if I can find time, will help you along...

 

Scot


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 8 of 10
scot-65
in reply to: AMC663

I did find a testing copy, however it is slightly different than what I attached earlier. Today I tweaked the first line so as protection from user canceling out while in the middle of the insert command (there are 2 pauses). I think this will work for you. I just noticed the insert command you show does not supply the attribute information? If so, then you need to suppress the attribute dialog box and supply the value while inside the insert command in order for this routine to work properly. Also, there is no second pause for rotation? If so, you will need to verify and adjust the orthomode (to off).
 
(command ".insert" "Name" pause x-scale y-scale pause "attribute01")
 

(defun C:Exit_Arrow (/ LA DS a b)
(setq LA (getvar "clayer"))
(setq DS (getvar "dimscale"))
(C:TTEXT)

(setvar 'ORTHOMODE 0)

(setvar 'ATTDIA 0)
(command "._insert" " Exit_Arrow " pause DS "" pause "EXIT")

 (if (= (cdr (assoc 0 (setq b (entget (setq a (entlast)))))) "INSERT")
  (while (/= (cdr (assoc 0 b)) "SEQEND")
   (setq b (entget (entnext (cdr (assoc -1 b)))))
   (if (= (cdr (assoc 0 b)) "ATTRIB")
    (progn
     (entmod (subst (cons 50 0.0) (assoc 50 b) b))
     (entupd a)
    );progn
   );if
  );while
 );if
 (setq a nil b nil)
(setvar "clayer" LA)
(princ))

 

 

???


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Message 9 of 10
AMC663
in reply to: scot-65

Hi Scot,

I am sorry for not getting back earlier.  I am the only cad guy left at work and I have a hard time to get away from it.
But yesterday, finally I got to your code.  Although not knowing much in programming I twisted it a bit and to my surprise it worked.  It was important for me to be able to enter values into the blocks, because I use these arrows to indicate how many people exiting from each office.

Your help was invaluable as now I have two new tools, one to reset attribute angle in selected blocks and now the other to insert them individually.

I heard this quote a long time ago:  “Torture numbers and they confess to anything”.  It seems like this applies to Lisp as well.

Thank you very much,

I surmise that this is not 100% proper, but here it is:

(defun C:Exit_Arrow (/ LA DS)
(setq LA (getvar "clayer"))
(setq DS (getvar "dimscale"))
(C:TTEXT)
(command "._insert" " EXIT_ARROW " pause DS "" pause "")
(princ)
  (if (setq sset (ssget "L"))
    (repeat (setq index (sslength sset))
      (setq attr (entnext (ssname sset (1- index))))
      (setq dxfdata (entget attr))
      (setq dxfdata (subst (cons 50 0.0) (assoc 50 dxfdata) dxfdata))
      (entmod dxfdata)
      (entupd attr)
      (setq index (1- index))
    )
  )
(setvar "clayer" LA)
(princ))

amicor@gmail.com

GS

Message 10 of 10
scot-65
in reply to: AMC663

🙂


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost