Results 1 to 4 of 4

Thread: Placing Block insertion points into Attribute data

  1. #1
    Member
    Join Date
    2002-11
    Posts
    19

    Default Placing Block insertion points into Attribute data

    I have a program that inserts a block and fills out the attributes. One of the attributes is the insertion point. Sort of like this:
    (setq int(cdr(assoc 10 ent))) ;Gets the insertion point. At this point the value of int = (6.44871e+006 1.92463e+008 0.0)
    When the block gets inserted:
    (command "INSERT" "MyBlock" "XSCALE" SYMSCALE "YSCALE" SYMSCALE int rot qty int ) ; qty is one attribute value and int is the other. After it's inserted the value of this attribute = 6.448797609824417E+006,1.924629241711203E+008
    Which is right on the money.
    That's the first thing I don't understand. What happened to 0.0?
    I am writing a program that has to update this value without replacing the block. I use:
    (setq ADDINS(cdr(assoc 10 AENTL))) ;Gets the ins point
    (setq X_VAL(rtos(car ADDINS)1 7)) ;Gets the X Value and turns it into a string
    (setq Y_VAL(rtos(cadr ADDINS)1 6)) ;Gets the Y Value and turns it into a string
    (setq ADDINN(strcat X_VAL "," Y_VAL )) ;Creates and comma delimited X,Y
    At this point the value of ADDINN is 6.4487057E+06,1.924629E+08 which is a little off.
    So I tried:
    (setq X_VAL(rtos(car ADDINS)2 7))
    (setq Y_VAL(rtos(cadr ADDINS)2 6))
    (setq ADDINN(strcat X_VAL "," Y_VAL ))
    To set it to a decimal value and it get this for a value:
    6448372.2599400,192462646.790151 which is way off.
    Is there any way I can get the original attribute value that Acad creates when the block gets inserted?

    If you need more info please let me know and thanks in advance for any advice.

  2. #2
    Past Vice President peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu Hawaii
    Posts
    575

    Default Re: Placing Block insertion points into Attribute data

    When I insert a block with attributes I usually allow the block to insert using the original default values of the attributes and the go back in and change the values afterward.

    insert the block with default values.
    (vl-cmdf "INSERT" "MyBlock" "XSCALE" SYMSCALE "YSCALE" SYMSCALE)
    (while (= (getvar "cmdactive") 1)(vl-cmdf ""))

    (setq entSelection (entlast)); get block entity

    Now there are two ways to manipulate the attributes. The first way is to use entnext

    (setq entAttribute (entnext entSelection))

    The other way is to use activeX which is my preferred way, but it may be too complicated for this situation.

    If you still are having trouble with this let me know and I will show you the rest of it.

    Peter

  3. #3
    Member
    Join Date
    2002-11
    Posts
    19

    Default Re: Placing Block insertion points into Attribute data

    Thanks Peter,
    It wasn't quite what I was after but it did make me stop and think. I have some limitations with some of my routines.
    1. They have to run on R14 (for now until I get the budget for a couple lic that the old cad manager failed to upgrade)
    2. When updating attributes they can't replace existing blocks. I have some VB6 routines that interface with the drawings and rely on the handle of the block object not changing.
    3. Some blocks are tied to each other by using the insertion point as a unique ID. That's why the insertion point is kept in an attribute. Some of the lisp routines compare these.
    If I create a block called MyBlock with one attribute called INSPOINT and insert it in the drawing using:
    (SETQ INPT(GETPOINT "ENTER INSERTION POINT..."))
    (command "INSERT" "CROSHAIR" "XSCALE" SYMSCALE "YSCALE" SYMSCALE INPT "" INPT)
    INPT has a value of (6.4488e+006 1.92463e+008 0.0)
    When I check the attribute INSPOINT afterward it has a value of 6.448797609824417E+006,1.924629241711203E+008
    Only X,Y not X,Y,Z ?
    Also a upper and lower case e which makes a difference when doing a string compare.
    What I find odd is the fact that I cannot recreate the insertion point string value that gets created when inserting a block. So I ended up creating a temp block with that attribute, insert it on the existing block, get the string, then erase it. Then using subst I update the exsisting block with that string. Not a prefered method but it works.

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    6,854

    Default Re: Placing Block insertion points into Attribute data

    Have you thought about using XDATA for your routines instead of using an attribute in a block. It does work with r14. Your VB code could also get that same information. I know that would require some revision to a number of your routines. Just a thought.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

Similar Threads

  1. Create a dynamic block with multiple insertion points
    By danielk in forum Dynamic Blocks - Technical
    Replies: 18
    Last Post: 2012-09-07, 08:38 AM
  2. Attribute in Dynamic Block does not prompt on insertion
    By matthew g. in forum AutoCAD Customization
    Replies: 9
    Last Post: 2010-09-03, 05:36 PM
  3. Is it possible for a Dynamic Block to have multiple Insertion Points
    By TerribleTim in forum Dynamic Blocks - Technical
    Replies: 10
    Last Post: 2007-06-16, 10:36 PM
  4. External data imported as block attribute
    By csj2005 in forum Land Desktop - General
    Replies: 0
    Last Post: 2007-05-25, 06:59 PM
  5. Creating points at block insertion points - HELP!
    By tcone00 in forum Land Desktop - General
    Replies: 4
    Last Post: 2007-01-10, 06:43 PM

Posting Permissions

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