TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Peter2 on October 27, 2014, 06:05:03 PM
-
Hi
in this thread Kerry showed some examples to get drawing info via DBX:
http://www.theswamp.org/index.php?topic=45935.msg510750#msg510750
The code
(defun kdub:listtextstyles ()
(kdub:listcollmbrnames (vla-get-textstyles kglobal:activedoc))
)
returns the names of the existing textstyles ("Standard", "Bold", "Thin",..), but I need the used fonts (isocp.shx, simplex.shx, arial.ttf) too.
Any ideas how to get them?
Thanks
Peter
-
Here's a quick example:
(defun textstylefonts
( doc
/ rtn
) )
)
Call with the Document object you wish to query:
You can use vlax-dump-object with a Textstyle object to view all available properties & methods.
-
Hi Lee
thanks a lot.
In the meantime I found a similar solution from the year 2006:
http://www.theswamp.org/index.php?topic=8587.msg109725#msg109725 (http://www.theswamp.org/index.php?topic=8587.msg109725#msg109725)
Regards
Peter
-
Quick and dirty start point:
(defun _GetTextStyles ( doc dxf_flag / @Try @GetStylePropsAX @GetStylePropsDXF @Main )
(defun @Try ( try_statement / try_result )
(vl-catch-all-apply
(function
(lambda ( )
(setq try_result (eval try_statement))
)
)
)
try_result
)
(defun @GetStylePropsAX ( style )
(mapcar
(function (lambda (p) (cons p (@Try '(vlax-get style p)))))
'( Name
BigFontFile
FontFile
Height
LastHeight
ObliqueAngle
TextGenerationFlag
Width
)
)
)
(defun @GetStylePropsDXF ( style )
(@Try
'(vl-remove-if
(function
(lambda ( p / key )
(or
(minusp (setq key (car p)))
(< 70 key)
(member key '(5))
)
)
)
(entget
(vlax-vla-object->ename style)
)
)
)
)
(defun @Main ( doc dxf_flag / func result )
(vl-load-com)
(setq func (if dxf_flag @GetStylePropsDXF @GetStylePropsAX))
(@Try
'(vlax-for style (vla-get-textstyles doc)
(setq result
(cons
(func style)
result
)
)
)
)
(reverse result)
)
(@Main doc dxf_flag)
)
Result (_GetTextStyles doc nil):
(
(
(NAME . "STANDARD")
(BIGFONTFILE . "")
(FONTFILE . "txt")
(HEIGHT . 0.0)
(LASTHEIGHT . 0.2)
(OBLIQUEANGLE . 0.0)
(TEXTGENERATIONFLAG . 0)
(WIDTH . 1.0)
)
(
(NAME . "SOME_MODEL|Standard")
(BIGFONTFILE . "")
(FONTFILE . "romans.shx")
(HEIGHT . 0.0)
(LASTHEIGHT . 2.5)
(OBLIQUEANGLE . 0.0)
(TEXTGENERATIONFLAG . 0)
(WIDTH . 1.0)
)
...
)
Result (_GetTextStyles doc T):
(
(
(0 . "STYLE")
(2 . "STANDARD")
(70 . 0)
(40 . 0.0)
(41 . 1.0)
(50 . 0.0)
(42 . 0.2)
(3 . "txt")
(4 . "")
)
(
(0 . "STYLE")
(2 . "SOME_MODEL|Standard")
(70 . 48)
(40 . 0.0)
(41 . 1.0)
(50 . 0.0)
(42 . 2.5)
(3 . "romans.shx")
(4 . "")
)
...
)
-
Great to see you posting code again MP :-)
-
Thanks to MP too.
This posting will go to my archive.
Peter
-
Thanks for the kind feedback guys. Wish I had time for more than the occasional 5 minute quick and dirty post. The good news is I'm so busy time is flying at break neck speed -- can't believe I've been with my employer over a year already -- feels like I started here just a couple months ago. :wack:
-
I swear, looking at MP's code is like walking through a fine art gallery.
-
I swear, looking at MP's code is like walking through a fine art gallery.
True, but it's a bit more functional than an old Rubins.
(http://clicks.robertgenn.com/images/artists/peter-paul_rubins/011607_peter-paul-rubins.jpg)
-
I swear, looking at MP's code is like walking through a fine art gallery.
True, but it's a bit more functional than an old Rubins.
More like....
http://www.angelfire.com/hiphop/diablo4u/remedios.html (http://www.angelfire.com/hiphop/diablo4u/remedios.html)
:-P
-
lol, in before macabre Hieronymus Bosch references :-D
-
(defun @GetStylePropsAX ( style ) ...
Do I understand it right that the ActiveX-method does not return the group-code 70 (Shape, vertical, external, ..)?
Peter
-
Bit flag states encoded in the 70 dxf group find residence in the TextGenerationFlag property.
-
OK, thanks :-)
Peter
-
You're most welcome Peter.