XY insert value to attribute?

XY insert value to attribute?

Anonymous
Not applicable
120 Views
3 Replies
Message 1 of 4

XY insert value to attribute?

Anonymous
Not applicable
Joe - This command does what you want:

(defun C:ATTORD ( / ss i)
(cond
( (not (setq ss (ssget '((0 . "INSERT") (66 . 1))))))
(t (setvar "CMDECHO" 0)
(command "._UNDO" "_Begin")
(repeat (setq i (sslength ss))
(attord (ssname ss (setq i (1- i))))
)
(command "._UNDO" "_En")
)
)
)

(defun attord (blk / att)
(entmod
(list
(cons -1 (setq att (entnext blk)))
(cons 1 (rtos (cadr (assoc 10 (entget att)))))
)
)
(entupd blk)
)

Joe Bailey wrote:
>
> I have a Block of a circle with an attribute inside. Is there a way to get
> the X value of the insertion point to become the value of the attribute.
> I'm trying to create a grid with XY values every 100 MM. I need to insert
> these blocks at the top and sides if the grid and have their respective XY
> values displayed.
>
> Thanks,
> Joe

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
0 Likes
121 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Joe - This command does what you want:

(defun C:ATTORD ( / ss i kword ord)
(cond
( (not (setq ss (ssget '((0 . "INSERT") (66 . 1))))))
(t (initget "X Y")
(setq kword (getkword "X or Y: "))
(setvar "CMDECHO" 0)
(setq ord
(if (eq kword "X") 'cadr 'caddr)
)
(command "._UNDO" "_Begin")
(repeat (setq i (sslength ss))
(attord (ssname ss (setq i (1- i))) ord)
)
(command "._UNDO" "_En")
)
)
)

(defun attord (blk ord / att)
(entmod
(list
(cons -1 (setq att (entnext blk)))
(cons 1 (rtos (apply ord (list (assoc 10 (entget att))))))
)
)
(entupd blk)
)

Joe Bailey wrote:
>
> I have a Block of a circle with an attribute inside. Is there a way to get
> the X value of the insertion point to become the value of the attribute.
> I'm trying to create a grid with XY values every 100 MM. I need to insert
> these blocks at the top and sides if the grid and have their respective XY
> values displayed.
>
> Thanks,
> Joe

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
0 Likes
Message 3 of 4

Anonymous
Not applicable
Perhaps you should not be hitting the refresh button
so often. It seems like you have absolutely nothing
to do with yourself, other than sit in front of your
computer hitting refresh on your newsreader, in what
appears to be an attempt to make this a real-time
live chat. Do you have a job?

So, yes. I did mistakenly post the code without the
option to choose whether he wants the X or Y, and
then realized that, pulled it, and posted a revised
copy.

Of course, you already know that.

Frank Oquendo wrote:
>
> I must confess to some confusion: how does one specify which attribute to
> place the value into? What if they want to place something other than the X
> ordinate in the attribute?
>
--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
0 Likes
Message 4 of 4

Anonymous
Not applicable
Frank Oquendo wrote:
>
> You're still assuming the first attribute encountered is the correct one.

You seem to have a comprehension problem.

Here is what Joe said:

"I have a Block of a circle with an attribute inside."

That's more ambiguous than "in order of on X,Y coordinates".

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
0 Likes