Author Topic: Help with Attribute Rotation problem  (Read 6697 times)

0 Members and 1 Guest are viewing this topic.

AVCAD

  • Guest
Help with Attribute Rotation problem
« on: October 23, 2007, 11:57:30 AM »
Ok...This is probably really easy for you guys but I am at a loss.

We have these standard toolbars that insert symbols and they scale automatically based off of what scale you want to draft at using a program that was written like 10 years ago.

We are upgrading to 2006 and the code that was previously written still works fine except there are embedded layering in the program that needs to change and I can't because the original unprotected code doesn't exist here anymore....go figure.

Anyways heres the problem.

In a Block, if you have attributes. Once you insert that block to a drawing and say its a power symbol, and the needs to be rotated (any degree it can be 0-360) how can you make that attribute in the block stay at 0 no matter what. I know it can be done because it is currently doing it, but I Have to rewrite this code and I cant figure out the last guy did it...

I know where to change it at, if I double click the block and then go to the TEXT option tab you can change the rotation there back to 0 but I don't want to go through that on every symbol.

I would post a video of it but I know how lol.

Thanks.


jonesy edit subject line changed

edited the subject line
« Last Edit: October 23, 2007, 03:36:50 PM by AVCAD »

deegeecees

  • Guest
Re: Challenge!
« Reply #1 on: October 23, 2007, 12:04:24 PM »
Iterate through the block entities, find the attributes' rotation DXF (don't rightly know what the number is off-hand) and change it to 0.

Do this with every inserted block?

Do this in a separate action after insertion?

Do it with Lisp?

*after previewing LE's post*

Used LE's sugg. yet?

AVCAD

  • Guest
Re: Challenge! - Automatically scale symbols
« Reply #2 on: October 23, 2007, 12:48:57 PM »
I love the Bubble code you wrote its pretty cool.

But all i am looking for is that routine to to grab that attribute info and make it stay at rotation 0 when first inserted

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Challenge! - Automatically scale symbols
« Reply #3 on: October 23, 2007, 12:56:46 PM »
I got code that does that, but i wont post it; ``challenge'', `challenge' for who?...This isnt a `challenge'.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

deegeecees

  • Guest
Re: Challenge! - Automatically scale symbols
« Reply #4 on: October 23, 2007, 12:57:12 PM »
You could use Torient in ACET as well.

Note: I'm not seeing the connection betwixed your intent, and the title of this thread.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Challenge! - Automatically scale symbols
« Reply #5 on: October 23, 2007, 01:05:32 PM »
I got code that does that, but i wont post it; ``challenge'', `challenge' for who?...This isnt a `challenge'.

will be nice, to remove the word 'challenge' from the topic.... since it is basically a request.... (and as always, make sure to post what you have done so far)

I agree!! I dont like `phishing'.  ...``Challenge'' heh! My code to rotate att's is in plain ALisp and about 10-15 lines long. Dont post under the guize of a popular game to get code you need/want.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

uncoolperson

  • Guest
Re: Challenge! - Automatically scale symbols
« Reply #6 on: October 23, 2007, 01:33:48 PM »
i remember a challenge that didn't get any submitted attempts because it was too difficult to do without having a purpose.

and now we're bashing on someone because they have a purpose in mind for a challenge of sorts?

deegeecees

  • Guest
Re: Challenge! - Automatically scale symbols
« Reply #7 on: October 23, 2007, 01:38:54 PM »
i remember a challenge that didn't get any submitted attempts because it was too difficult to do without having a purpose.

and now we're bashing on someone because they have a purpose in mind for a challenge of sorts?

Not necessarily 'Bashing', but more of a "Callin' You Out" kind of feel here. In the first place the poster says he wants to "scale" symbols. There is nothing in the posters requests that suggests any type of scaling of anything. Second, anyone who puts "Challenge!" to start the thread topic, is merely attempting to entice someone into creating this for them. Not gonna happen here. I hope that clears things up a bit.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Challenge! - Automatically scale symbols
« Reply #8 on: October 23, 2007, 02:08:02 PM »
If you notice, the title was changed, the original title was just ``Challenge!''.

And no im not bashing, just saying that i dont agree with the tactics. Fell free to do as you wish, If i dont agree i wont participate. I may warn you that i dont agree, like i did here, but thats only to make a point (you can then choose to take it or leave it...i dont care either way.).
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

AVCAD

  • Guest
Re: Challenge! - Automatically scale symbols
« Reply #9 on: October 23, 2007, 02:12:05 PM »
actually your wrong, someone changed the title of this thread and it wasn't me. Although yes it did say Challenge

I have no clue why it says scale symbols this has nothing to do with scaling symbols.

Taking this personally a bit arn't you? I dont want you write anything I just wanted to know if there was an easy way of doing it, like a variable i access or how I can access the attribute info inside a block and chance it with out having to double click the block, but looks like some of you need to have a donut.

Thanks for the other who actually helped, guess I will go figure it out myself instead of asking for help so i didn't have to spend hours looking with no idea what I am looking for.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Challenge! - Automatically scale symbols
« Reply #10 on: October 23, 2007, 02:50:58 PM »

actually your wrong, someone changed the title of this thread and it wasn't me. Although yes it did say Challenge

I have no clue why it says scale symbols this has nothing to do with scaling symbols.

Taking this personally a bit arn't you? I dont want you write anything I just wanted to know if there was an easy way of doing it, like a variable i access or how I can access the attribute info inside a block and chance it with out having to double click the block, but looks like some of you need to have a donut.

Thanks for the other who actually helped, guess I will go figure it out myself instead of asking for help so i didn't have to spend hours looking with no idea what I am looking for.

Who's wrong? No one said anything to be wrong about. At the bottom of your initial post is a comment read it.

I *am* trying to help. And I dont know why you cant see that. If you honestly tried to ask, it was a very crappy attempt.

I am not taking anything personal; how could i? I dont care if you get your task complete. Its not a need of mine, so I have no stake in the matter other then to try and help you. And the only way I can see to help you is to tell you that your tactics of `asking' will not get you very far in this or future problems. So even though I found your tactics rude I offered help anyways. (Albeit in a rude manner, but that is how you ``treated me'' so I returned the favor. Are you angry at me for that?)

READ THIS!!
[ http://www.catb.org/~esr/faqs/smart-questions.html ]
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

M-dub

  • Guest
Re: Challenge! - Automatically scale symbols
« Reply #11 on: October 23, 2007, 02:52:48 PM »
Alright, alright...

Maverick®

  • Seagull
  • Posts: 14778
Re: Challenge! - Automatically scale symbols
« Reply #12 on: October 23, 2007, 03:01:41 PM »
   Avcad.  Could you please change the thread title to what you are looking for.  I don't think Jonesy really knew so she winged it.  No foul.

 
  I think the OP could have titled the thread a little better but I personally didn't read his post as asking someone to write it for him.

  Mountains and molehills people.  This is the great tube network. Make rude hand gestures towards the monitor at your convenience and move on to helpful things.


Please.

Josh Nieman

  • Guest
Re: Challenge! - Automatically scale symbols
« Reply #13 on: October 23, 2007, 03:05:10 PM »
Careful with the hand gestures though, we don't want anyone getting hurt.

Maverick®

  • Seagull
  • Posts: 14778
Re: Challenge! - Automatically scale symbols
« Reply #14 on: October 23, 2007, 03:14:45 PM »
Good thing I have an LCD.  Can't do that with those.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Challenge! - Automatically scale symbols
« Reply #15 on: October 23, 2007, 03:27:44 PM »
*sigh*

*Se7en hangs his head and walks away with out being able to finish the lesson yet again.*
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Maverick®

  • Seagull
  • Posts: 14778
Re: Challenge! - Automatically scale symbols
« Reply #16 on: October 23, 2007, 03:30:56 PM »
*Hummms "gloom, despair, and agony on me" (HeeHaw)*


You're not going to "finish your lesson" by driving the students out of the classroom.

AVCAD

  • Guest
Help with attribute rotation problem
« Reply #17 on: October 23, 2007, 03:40:18 PM »
   Avcad.  Could you please change the thread title to what you are looking for.  I don't think Jonesy really knew so she winged it.  No foul.

I updated it, sorry for the confusion.

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Help with Attribute Rotation problem
« Reply #18 on: October 23, 2007, 03:41:13 PM »
Who's driving them out. I am only telling it like it is, you are the ones making jokes. There is no animosity on my end.

AVCAD is a grownup, we can have discussions on theory, ideals and feelings without fluffy pillows and flowers and not hold any grudges towards each other. If it makes you feel better we can finish this via PM.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

LE

  • Guest
Re: Help with Attribute Rotation problem
« Reply #19 on: October 23, 2007, 11:18:10 PM »
Forget my previous posts....

This little code, will know when a block was inserted (via: drag-&-drop, insert, a double-click from a palette or pasted) and if it has attributes, that are rotated, it will force to change them to be 0.0 (horizontal)
it is just a start - try to add more features or your own controls, and error handler - please.

Have fun.

Code: [Select]
;;8:08 PM 10/23/2007

(defun attsrotcontrol-event  (reactor params / vla_block vla_atts)
  (if (wcmatch
        (car params)
        "DROPGEOM,EXECUTETOOL,ACDCINSERTBLOCK,INSERT,PASTEBLOCK")
    (progn (setq vla_block (vlax-ename->vla-object (entlast)))
           (if (= (vla-get-hasattributes vla_block) :vlax-true)
             (progn (setq vla_atts
                           (vlax-safearray->list
                             (vlax-variant-value (vla-getattributes vla_block))))
                    (mapcar (function
                              (lambda (att)
                                (if (> (vla-get-rotation att) 0.0) ;; add a better condition!
                                  (vla-put-rotation att 0.0)))) ;; add a better rotation control!
                            vla_atts))))))

(defun attsrotcontrol-on  ()
  (if (not attsrotcontrol_reactor)
    (setq attsrotcontrol_reactor
           (vlr-editor-reactor
             "attributes rotation control"
             '((:vlr-commandended . attsrotcontrol-event)))))
  (prompt "\nAttributes rotation control - enabled. \n")
  (princ))

(defun attsrotcontrol-off  ()
  (if attsrotcontrol_reactor
    (progn (if (vlr-added-p attsrotcontrol_reactor)
             (vlr-remove attsrotcontrol_reactor))
           (setq attsrotcontrol_reactor nil)
           (prompt "\nAttributes rotation control - disabled. \n")))
  (princ))

(defun C:ATTROTON () (attsrotcontrol-on) (princ))
(defun C:ATTROTOFF () (attsrotcontrol-off) (princ)) ;; EDIT added the off command...

(if (not (vl-bb-ref ':attsrotcontrol_banner))
  (progn (vl-bb-set ':attsrotcontrol_banner t)
         (princ "\n[ Attributes Rotation Control ] Loaded. \n")))

(princ)
« Last Edit: October 23, 2007, 11:25:30 PM by LE »

GDF

  • Water Moccasin
  • Posts: 2081
Re: Help with Attribute Rotation problem
« Reply #20 on: October 24, 2007, 10:50:27 AM »
Try this out for an example. Inserts a north arrow and rotates the attribute horizontally automatically.

ARCH#CUSF equals your path to where the block can be found.

Code: [Select]
(defun ARCH:BLKNAM  (blknam path / e)
  (setq e (tblobjname "BLOCK" blknam))
  (if e
    (command "insert" (strcat blknam "=" path blknam) (command)))
  (princ))

(defun c:SYMTNR  (/ cmdecho attdia ins ent rot use north scf tmp)
  (if (= ARCH#BLKX nil)
    (ARCH:BLKNAM "SYMTNR" (strcat ARCH#CUSF "SYMS/")))
  ;;(ARCH:F_S-VAR)
  (setq scf (getvar "dimscale"))
  (setq cmdecho (getvar "CMDECHO"))
  (setq attdia (getvar "ATTDIA"))
  (setvar "ATTDIA" 0)
  (prompt "\n* Pick insertion point and then pick rotation angle *")
  ;;(ARCH:CUSTOM_LAYERS-SYMB-NARR) ;cutom layer creator
  (setvar "cmdecho" 0)
  (initget "P T")
  (setq tmp (getkword "\n* Select One: <Plan> <True> *"))
  (progn (if (= tmp "P")
           (setq NORTH "PLAN NORTH"))
         (if (or (= tmp "T") (= tmp nil))
           (setq NORTH "TRUE NORTH")))
  (command
    "insert"
    (strcat ARCH#CUSF "SYMS/" "SYMTNR")
    "ps"
    SCF
    pause
    SCF
    ""
    pause
    NORTH
    "")
  (initdia 1)
  (while (eq 1 (logand 1 (getvar "CMDACTIVE"))) (command pause))
  (setq ins (entlast))
  (setq ent (entget ins))
  (setq pnt (cdr (assoc 10 ent)))
  (setq rot (cdr (assoc 50 ent)))
  (setq use (* (/ rot pi) 180.0))
  (setq use (- 0.0 use))
  (command "_.ROTATE" ins "" pnt use)
  (setq ent (subst (cons 50 rot) (assoc 50 ent) ent))
  (entmod ent)
  (setvar "ATTDIA" attdia)
  (setvar "CMDECHO" cmdecho)
  ;;(ARCH:F_R-VAR)
  (princ))
;;true north

Gary
« Last Edit: October 24, 2007, 11:27:20 AM by Gary Fowler »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Help with Attribute Rotation problem
« Reply #21 on: October 24, 2007, 11:04:47 AM »
Nice code guys. Two totally different methods.
LE, you gave me a great idea.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CADaver

  • Guest
Re: Help with Attribute Rotation problem
« Reply #22 on: October 24, 2007, 11:17:37 AM »
Nice code guys. Two totally different methods.
LE, you gave me a great idea.

Gee, we learned something from code actually posted.  Imagine that.

http://www.theswamp.org/index.php?topic=2621.msg33156#msg33156

deegeecees

  • Guest
Re: Help with Attribute Rotation problem
« Reply #23 on: October 24, 2007, 11:29:58 AM »
Nice code guys. Two totally different methods.
LE, you gave me a great idea.

Gee, we learned something from code actually posted.  Imagine that.

http://www.theswamp.org/index.php?topic=2621.msg33156#msg33156

Yeah, I found this snippet to be interesting enough:

Quote from: LE
(if (wcmatch
        (car params)
        "DROPGEOM,EXECUTETOOL,ACDCINSERTBLOCK,INSERT,PASTEBLOCK")
    (progn (setq vla_block (vlax-ename->vla-object (entlast)))

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Help with Attribute Rotation problem
« Reply #24 on: October 24, 2007, 12:08:27 PM »
Nice code guys. Two totally different methods.
LE, you gave me a great idea.

Gee, we learned something from code actually posted.  Imagine that.

http://www.theswamp.org/index.php?topic=2621.msg33156#msg33156

Straight to the point: So you didnt read the link i posted? (Read the intro.)

...Code is easy. I bet the code LE posted didnt take him any time at all, but getting to the bottom of the initial problem took him longer; I for one dont like wasting his time.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Help with Attribute Rotation problem
« Reply #25 on: October 24, 2007, 12:12:51 PM »
Good grief John, let it go.

Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

JohnK

  • Administrator
  • Seagull
  • Posts: 10648
Re: Help with Attribute Rotation problem
« Reply #26 on: October 24, 2007, 12:20:36 PM »
Good grief John, let it go.
...
Maybe your right. I obviously haven't learned either.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org