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

0 Members and 1 Guest are viewing this topic.

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