Jump to content

Recommended Posts

Posted

Hello,

 

I have been pulling my hair out for the last few days (i'm almost bald now), and i have not been able to get this command correct. I have been reading forums and getting plenty of information on how to update attributes within blocks, but i can't seem to combine that with grabbing a Z value of the block (or attribute) to populate the Attribute field.

 

Any assistance would be greatly appreciated. I have not tried to create anything more than simple LISP routines, so please assume i know nothing in your responses.

 

Thanks

 

 

 

(defun c:sdh2 (/ blks i sn n e)

;;; The Loop i'm using, not sure if it works

 

(if (setq blks (ssget '((0 . "INSERT") (66 . 1))))

(repeat (setq i (sslength blks))

(setq sn (ssname blks (setq i (1- i))))

(setq n (entnext sn))

(while

(not

(eq (cdr (assoc 0 (setq e (entget n))))

"SEQEND"

)

)

(if (eq (cdr (assoc 0 e)) "ATTRIB")

 

;;; My Specific Attribute Name within the block

(cond ((eq (cdr (assoc 2 e)) "DH")

 

;;; May attempt to grab the Z Height

;;; returns error: bad argument type: consp 90.468

;;; 90.468 being the correct z height value i want on this particular block

(setq z (cdr(nth 3(assoc 10 e))))

 

(entmod (subst (cons 1 z) (assoc 1 e) e))

)

)

)

(setq n (entnext n))

)

)

)

(princ)

)

Posted

I just had what alcoholics refer to as a "moment of clarity" and got it figured out. On the off chance someone else needs it, here it is below. i was not formatting my Z value correctly. it now is formatted as (1 . "ZHEIGHT") which is what the attribute required.

 

 

(defun c:sdh (/ blks i sn n e)

;;; Set Default Height on all Cap Blocks

 

(if (setq blks (ssget '((0 . "INSERT") (66 . 1))))

(repeat (setq i (sslength blks))

(setq sn (ssname blks (setq i (1- i))))

(setq n (entnext sn))

(while

(not

(eq (cdr (assoc 0 (setq e (entget n))))

"SEQEND"

)

)

(if (eq (cdr (assoc 0 e)) "ATTRIB")

 

(cond ((eq (cdr (assoc 2 e)) "DH")

 

(setq z (cdr(assoc 10 e)))

(setq z (caddr z))

(setq z (rtos z 2 6))

 

(entmod (subst (cons 1 z) (assoc 1 e) e))

)

)

)

(setq n (entnext n))

)

)

)

(princ)

)

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...