Author Topic: Trouble to create an atribute block  (Read 4724 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
Trouble to create an atribute block
« 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.
Code: [Select]
; 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




HofCAD

  • Guest
Re: Trouble to create an atribute block
« Reply #1 on: June 14, 2007, 09:31:00 AM »
Hello Adesu,

What do You mean:

 (command "_-wblock" bn "" bp ss "")
or
 (command "_-block" bn bp ss "")
 
Regards,
HofCAD CSI

kpblc

  • Bull Frog
  • Posts: 396
Re: Trouble to create an atribute block
« Reply #2 on: June 14, 2007, 04:10:25 PM »
Try to change sysvar "attreq".
Sorry for my English.

Adesu

  • Guest
Re: Trouble to create an atribute block
« Reply #3 on: June 14, 2007, 09:16:25 PM »
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
Code: [Select]
; 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".

Adesu

  • Guest
Re: Trouble to create an atribute block
« Reply #4 on: June 14, 2007, 09:18:17 PM »
I mean don't want white text in that drawing, it should disappeared and that drawing would become a block.

kpblc

  • Bull Frog
  • Posts: 396
Re: Trouble to create an atribute block
« Reply #5 on: June 15, 2007, 01:16:45 AM »
I don't understand - the white texts are an ATTRIBUTES, not TEXT. So 'cos of this they're not processed.
Sorry for my English.

Adesu

  • Guest
Re: Trouble to create an atribute block
« Reply #6 on: June 15, 2007, 03:33:38 AM »
Hi kpblc,
if you use attedit, it would like this
Code: [Select]
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.

kpblc

  • Bull Frog
  • Posts: 396
Re: Trouble to create an atribute block
« Reply #7 on: June 15, 2007, 05:40:53 AM »
Look an attachment
« Last Edit: June 15, 2007, 05:43:58 AM by kpblc »
Sorry for my English.

HofCAD

  • Guest
Re: Trouble to create an atribute block
« Reply #8 on: June 15, 2007, 07:00:40 AM »
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
« Last Edit: June 15, 2007, 07:42:11 AM by HofCAD »

Adesu

  • Guest
Re: Trouble to create an atribute block
« Reply #9 on: June 17, 2007, 08:16:02 PM »
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

Adesu

  • Guest
Re: Trouble to create an atribute block
« Reply #10 on: June 17, 2007, 09:20:43 PM »
Hi kpblc,
I just tested your code is great, thanks for your help.

Look an attachment