PDA

View Full Version : Placing Block insertion points into Attribute data


mcoonrod
2005-10-22, 06:50 PM
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.

peter
2005-10-23, 02:51 PM
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

mcoonrod
2005-10-24, 04:57 PM
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.

Opie
2005-10-24, 05:03 PM
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.