TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Adesu on June 13, 2007, 12:23:02 AM
-
Hi Alls,
Here my code to create an atribute block, but this code still trouble at function in block, because if you create in manual system you would get attribut dialog before finish it.
; cad is stand for Create Attribute Definition
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 15 March 2007
; Program no.: 0559/03/2007
; Edit by : Adesu 12/06/2007 1).
; 13/06/2007 2).
(defun c:cad (/ ad ang cnt etyp ht prom rot sp ss sse ssl ssn str tag th val)
(setq ad (getvar "attdia"))
(if
(= ad 1)
(setvar "attdia" 0)
) ; if
(princ "\nSelect by polygon alls text")
(if
(setq ss (ssget '((0 . "TEXT"))))
(progn
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(setq sse (entget ssn))
(setq etyp (cdr (assoc 0 sse)))
(if
(= etyp "TEXT")
(progn
(setq sp (cdr (assoc 10 sse)))
(setq str (cdr (assoc 1 sse)))
(setq ht (cdr (assoc 40 sse)))
(setq ang (cdr (assoc 50 sse)))
(setq tag
(getstring t
(strcat "\nEnter name for tag< " str " >: ")))
(setq prom
(getstring t
(strcat "\nEnter name for prompt< " str " >: ")))
(setq val str)
(setq th (getdist (strcat "\nEnter new text height< " (rtos ht) " >: ")))
(if (= th nil)(setq th ht))
(setq rot (getdist (strcat "\nEnter new rotation< " (rtos ang) " >: ")))
(if (= rot nil)(setq rot ang))
(command "_attdef" "i" "" tag prom val sp th rot)
) ; progn
) ; if
(setq cnt (1+ cnt)) ; 1).
) ; repeat
) ; progn
) ; if
(setq path "D:/YBI/Drawing/Data Base/Block/") ; 2).
(setq bn (getstring t "\nEnter name for block: ")) ; 1).
(setq loc (strcat path bn)) ; 2).
(setq bp (getpoint "\nClick as base point block: ")) ; 1).
(prompt "\nSelect object would become block")
(setq ss (ssget))
(command "_-block" bn "" bp ss "")
(setq pt (getpoint "\nClick any location: ")) ; 2).
(command "insert" bn pt "" "" "") ; 2).
(setvar "attdia" ad)
(princ)
) ; defun
-
Hello Adesu,
What do You mean:
(command "_-wblock" bn "" bp ss "")
or
(command "_-block" bn bp ss "")
Regards,
HofCAD CSI
-
Try to change sysvar "attreq".
-
Hi kpblc,
I just added my code with "attmode", but finish result that block not yet a block as I want,look at attach file.
Here my code after revised
; cad is stand for Create Attribute Definition
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 15 March 2007
; Program no.: 0559/03/2007
; Edit by : Adesu 12/06/2007 1).
; 13/06/2007 2).
; 15/06/2007 3).
(defun c:cad (/ ad ang cnt etyp ht prom rot sp ss sse ssl ssn str tag th val)
(setq ad (getvar "attdia"))
(if
(= ad 1)
(setvar "attdia" 0)
) ; if
(setq am (getvar "attmode")) ; 3).
(if
(/= am 2)
(setvar "attmode" 2)
) ; if
(princ "\nSelect by polygon alls text")
(if
(setq ss (ssget '((0 . "TEXT"))))
(progn
(setq ssl (sslength ss))
(setq cnt 0)
(repeat
ssl
(setq ssn (ssname ss cnt))
(setq sse (entget ssn))
(setq etyp (cdr (assoc 0 sse)))
(if
(= etyp "TEXT")
(progn
(setq sp (cdr (assoc 10 sse)))
(setq str (cdr (assoc 1 sse)))
(setq ht (cdr (assoc 40 sse)))
(setq ang (cdr (assoc 50 sse)))
(setq tag
(getstring t
(strcat "\nEnter name for tag< " str " >: ")))
(setq prom
(getstring t
(strcat "\nEnter name for prompt< " str " >: ")))
(setq val str)
(setq th (getdist (strcat "\nEnter new text height< " (rtos ht) " >: ")))
(if (= th nil)(setq th ht))
(setq rot (getdist (strcat "\nEnter new rotation< " (rtos ang) " >: ")))
(if (= rot nil)(setq rot ang))
(command "_attdef" "i" "" tag prom val sp th rot)
) ; progn
) ; if
(setq cnt (1+ cnt)) ; 1).
) ; repeat
) ; progn
) ; if
;(setq path "D:/YBI/Drawing/Data Base/Block/") ; 2).
(setq bn (getstring t "\nEnter name for block: ")) ; 1).
;(setq loc (strcat path bn)) ; 2).
(setq bp (getpoint "\nClick as base point block: ")) ; 1).
(prompt "\nSelect object would become block")
(setq ss (ssget))
(command "_-block" bn "" bp ss "")
;(setq pt (getpoint "\nClick any location: ")) ; 2).
;(command "insert" bn pt "" "" "") ; 2).
(setvar "attdia" ad)
(setvar "attmode" am) ; 3).
(princ)
) ; defun
Try to change sysvar "attreq".
-
I mean don't want white text in that drawing, it should disappeared and that drawing would become a block.
-
I don't understand - the white texts are an ATTRIBUTES, not TEXT. So 'cos of this they're not processed.
-
Hi kpblc,
if you use attedit, it would like this
Command: attedit
Select block reference: That object is not a block.
Select block reference: *Cancel*
I'm not yet understand what wrong in my code.
I don't understand - the white texts are an ATTRIBUTES, not TEXT. So 'cos of this they're not processed.
-
Look an attachment
-
I mean don't want white text in that drawing, it should disappeared and that drawing would become a block.
Hello Adesu,
What do You mean:
(command "_-wblock" bn "" bp ss "")
or
(command "_-block" bn bp ss "")
I think, You mean (command "_-wblock" bn "" bp ss "") instead of (command "_-block" bn "" bp ss "")
Regards,
HofCAD CSI
-
Hi HofCAD,
Very sorry I late to correction your suggest, your suggest it's great it can solve my problem,thanks you very much.
I mean don't want white text in that drawing, it should disappeared and that drawing would become a block.
Hello Adesu,
What do You mean:
(command "_-wblock" bn "" bp ss "")
or
(command "_-block" bn bp ss "")
I think, You mean (command "_-wblock" bn "" bp ss "") instead of (command "_-block" bn "" bp ss "")
Regards,
HofCAD CSI
-
Hi kpblc,
I just tested your code is great, thanks for your help.
Look an attachment