+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Forum Newbie
    Computer Details
    sbrennan85's Computer Details
    Operating System:
    Windows 7 64-bit
    Motherboard:
    Asus P5K
    CPU:
    Intel Core 2 Quad Q6600 @ 2.4GHz
    RAM:
    8GB DDR2 667MHz
    Graphics:
    Dual ATI Radeon HD 2900XT 1GB
    Monitor:
    (3) Acer AL2216
    Discipline
    Electrical
    sbrennan85's Discipline Details
    Occupation
    Design Engineer
    Discipline
    Electrical
    Using
    MEP 2012
    Join Date
    Apr 2012
    Location
    Chicagoland
    Posts
    2

    Default Looking to *Insert Dynamic Block and rotate Dynamic Grip*

    Registered forum members do not see this ad.

    Ok, so I recently found how I can apply a dynamic rotation to a block, keep the text/attribute positioning relative to the original location, but not actually rotate. It's perfect and I'm excited to implement it in my company.

    However, I'm also working on a few ribbon tabs that will have a bunch of these blocks (different symbols and/or attributes). Right now I'm simply using macros to insert the block, and bypass any steps necessary for that particular block (scale, rotate, etc). However, with a traditional block I need to use a LISP routine that was created years ago here at our company to rotate the attributes (I think it was created before AutoCAD had the function? I don't know, I've only been using CAD for about 8.5 years).

    I'm trying to do the following in as much automation as possible:
    1. Insert Dynamic Block
    2. Scale based on USERR1 value
    3. Force rotation to 0 degrees
    4. Allow for user input of Attribute(s)
    5. Select the (only) Dynamic Rotation Grip
    6. Allow for user input of Dynamic Rotation
    7. Repeat all of the above until cancelled
    I'm pretty sure this is only doable via LISP, but I know NOTHING about LISP programming, and was hoping someone could help out.


    I've attached one of the many blocks I have with this "auto-aligning" text feature.


    Thanks in advance!
    Attached Files

  2. #2
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,684

    Default

    Registered forum members do not see this ad.

    Try this code:
    Code:
    (defun C:bpro(/ acsp adoc attvalue blkname blkobj prop_lst prop_names pt scl )
      (or adoc (setq adoc (vla-get-activedocument (vlax-get-acad-object))))
      (if (and (= (getvar "tilemode") 0) (= (getvar "cvport") 1))
        (setq acsp (vla-get-paperspace adoc))
        (setq acsp (vla-get-modelspace adoc))
      )
    (vla-startundomark adoc)
     
    (setq blkname "RECEPTACLE-DUPLEX-PLAY");<-- block name
     
    (if (not (tblsearch "block" blkname))(progn
      (alert "No such block in drawing, exit.")
      (exit)(princ))
      )
     
      (if (= 0 (setq scl (getvar "USERR1")))
        (setq scl (getreal "\nEnter User scale value: "))
        (setvar "USERR1" scl)
        )
     
     (while (setq pt (getpoint "\nPick insertion point (Or press Enter to Exit): "))
    (setq blkobj (vlax-invoke acsp 'insertblock pt blkname  scl scl scl 0))
    (if (eq :vlax-true
     (vla-get-isdynamicblock
       (vla-item
         (vla-get-blocks
           (vla-get-activedocument (vlax-get-acad-object))
         )
         (vla-get-effectivename blkobj)
       )
     )
        )
      (progn
        (setq prop_names
        (mapcar 'vla-get-propertyname
         (setq
           prop_lst
            (vlax-safearray->list
       (vlax-variant-value
         (vla-getdynamicblockproperties blkobj)
       )
            )
         )
        )
        )
        (foreach prop prop_lst
          (if (and (eq "Angle1" (vla-get-propertyname prop))
            (member "Angle1" prop_names)
       )
     (vla-put-value
       prop
       (vlax-make-variant
         0.0
         (vlax-variant-type (vla-get-value prop))
       )
     )
          )
        )
      )
    )
    (setq attvalue (getstring T  "\nEnter attribute value for CCT : "))
       (foreach att (vlax-invoke blkobj 'getattributes)
         (if (eq "CCT" (vla-get-tagstring att))
          (vla-put-textstring att attvalue)
           )
         )
     
     
    )
     
    (princ)
    )
    (prompt "\nType BPRO to run the command")
    (prin1)
    (or (vl-load-com)
        (princ))
    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

Similar Threads

  1. Dynamic Block Grip Question
    By LaneClare in forum AutoCAD Drawing Management & Output
    Replies: 17
    Last Post: 28th Feb 2014, 05:20 pm
  2. Insert dynamic block from file with multiple dynamic blocks
    By BUrBaKy in forum AutoCAD Drawing Management & Output
    Replies: 17
    Last Post: 14th Nov 2012, 11:38 pm
  3. Dynamic Block Grip Problem
    By breaked_burial in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 15th Sep 2011, 05:13 pm
  4. dynamic insert of a dynamic block.
    By Huibert in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 13th Jun 2010, 02:12 am
  5. dynamic block grip problem
    By michaeloureiro in forum AutoCAD General
    Replies: 15
    Last Post: 30th Jan 2009, 11:27 am

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts