TheSwamp
Code Red => VB(A) => Topic started by: ML on November 04, 2004, 07:51:33 PM
-
Would anyone happen to have a module that would convert plain text to a Block Attribute?
Once it is an attribute, I can tweak it from there
Thank you
Mark
-
Hi
"Moudule" meaning VBA or will LISP do?
Below is from an old AUGI LISP Guild post by Jim Fisher -
;|Creates a block definition with an attribute using the block and tag names you specify. It then loops through all the text you selected and creates an insert using the text value as the value for the attribute.|;
(defun c:txt2blk (/ blkName tagName ss index
el txtHt txtStyl txtHorJust
txtVertJust txtLyr blkPt blkHt
attStr blkRot alignPt en
)
(setq
blkName (getstring "\nBlock name: ")
tagName (getstring "\nTag name: ")
ss (ssget '((0 . "text")))
)
(cond
((not ss)
(prompt "\nNo text selected.\n")
)
('T
(setq
index 0
el (entget (ssname ss index))
txtHt (cdr (assoc 40 el))
txtStyl (cdr (assoc 7 el))
txtHorJust (cdr (assoc 72 el))
txtVertJust (cdr (assoc 73 el))
)
(entmake
(list
(cons 0 "block")
(cons 2 blkName)
(cons 70 2)
(cons 10 '(0.0 0.0 0.0))
)
)
(entmake
(list
(cons 0 "attdef")
(cons 10 '(0.0 0.0 0.0))
(cons 40 txtHt)
(cons 1 "")
(cons 3 "Enter a value")
(cons 2 tagName)
(cons 70 0)
(cons 7 txtStyl)
(cons 72 txtHorJust)
(cons 74 txtVertJust)
)
)
(entmake '((0 . "endblk")))
(repeat (sslength ss)
(setq
en (ssname ss index)
el (entget en)
txtLyr (cdr (assoc 8 el))
blkPt (cdr (assoc 10 el))
blkHt (cdr (assoc 40 el))
attStr (cdr (assoc 1 el))
blkRot (cdr (assoc 50 el))
txtStyl (cdr (assoc 7 el))
txtHorJust (cdr (assoc 72 el))
txtVertJust (cdr (assoc 73 el))
alignPt (cdr (assoc 11 el))
index (1+ index)
)
(entmake
(list
(cons 0 "insert")
(cons 2 blkName)
(cons 8 txtlyr)
(cons 10 blkPt)
(cons 41 (/ blkHt txtHt))
(cons 42 (/ blkHt txtHt))
(cons 43 (/ blkHt txtHt))
(cons 50 blkRot)
(cons 66 1)
)
)
(entmake
(list
(cons 0 "attrib")
(cons 8 txtLyr)
(cons 10 blkPt)
(cons 40 blkHt)
(cons 1 attStr)
(cons 2 tagName)
(cons 70 0)
(cons 50 blkRot)
(cons 7 txtStyl)
(cons 72 txtHorJust)
(cons 74 txtVertJust)
(cons 11 alignPt)
)
)
(entmake
(list
(cons 0 "seqend")
(cons 8 txtLyr)
)
)
(entdel en)
)
(redraw)
)
)
(princ)
)
Have a good one, Mike
-
Hi Mike
I prefer VBA because I am more comfortable with it but nonetheless, I really appreciate it
I will give it a try
Thank you
Mark
-
Hey Mike
That is a nice little routine.
I would like it to go just a few steps further as far as asking you if you want your Attribute to be prest, constant, invisible etc.
Also, after idefine the attribute, I wblock it out
Also, a dialog box interface would be great. That is where VBA would come into play.
Thanks
Mark