Author Topic: How to get entire texstyle info via DBX?  (Read 4620 times)

0 Members and 1 Guest are viewing this topic.

Peter2

  • Swamp Rat
  • Posts: 653
How to get entire texstyle info via DBX?
« 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
Code: [Select]
(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

Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to get entire texstyle info via DBX?
« Reply #1 on: October 27, 2014, 06:26:37 PM »
Here's a quick example:
Code - Auto/Visual Lisp: [Select]
  1. (defun textstylefonts ( doc / rtn )
  2.     (vlax-for sty (vla-get-textstyles doc)
  3.         (setq rtn (cons (cons (vla-get-name sty) (vla-get-fontfile sty)) rtn))
  4.     )
  5.     (reverse rtn)
  6. )

Call with the Document object you wish to query:
Code - Auto/Visual Lisp: [Select]

You can use vlax-dump-object with a Textstyle object to view all available properties & methods.
« Last Edit: October 27, 2014, 06:30:41 PM by Lee Mac »

Peter2

  • Swamp Rat
  • Posts: 653
Re: How to get entire texstyle info via DBX?
« Reply #2 on: October 27, 2014, 06:38:49 PM »
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

Regards

Peter
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to get entire texstyle info via DBX?
« Reply #3 on: October 27, 2014, 07:26:47 PM »
Quick and dirty start point:

Code: [Select]
(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 . "")
    )
    ...
)
« Last Edit: October 27, 2014, 07:35:51 PM by MP »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to get entire texstyle info via DBX?
« Reply #4 on: October 27, 2014, 07:46:55 PM »
Great to see you posting code again MP :-)

Peter2

  • Swamp Rat
  • Posts: 653
Re: How to get entire texstyle info via DBX?
« Reply #5 on: October 27, 2014, 07:57:54 PM »
Thanks to MP too.

This posting will go to my archive.

Peter
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to get entire texstyle info via DBX?
« Reply #6 on: October 27, 2014, 09:01:45 PM »
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:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How to get entire texstyle info via DBX?
« Reply #7 on: October 28, 2014, 05:51:47 PM »
I swear, looking at MP's code is like walking through a fine art gallery.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to get entire texstyle info via DBX?
« Reply #8 on: October 28, 2014, 05:57:48 PM »
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.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: How to get entire texstyle info via DBX?
« Reply #9 on: October 28, 2014, 06:01:25 PM »
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
 :-P
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to get entire texstyle info via DBX?
« Reply #10 on: October 28, 2014, 06:49:26 PM »
lol, in before macabre Hieronymus Bosch references :-D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Peter2

  • Swamp Rat
  • Posts: 653
Re: How to get entire texstyle info via DBX?
« Reply #11 on: October 29, 2014, 07:15:12 PM »
Code: [Select]
(defun @GetStylePropsAX ( style ) ...
Do I understand it right that the ActiveX-method does not return the group-code 70 (Shape, vertical, external, ..)?

Peter
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to get entire texstyle info via DBX?
« Reply #12 on: October 29, 2014, 07:26:54 PM »
Bit flag states encoded in the 70 dxf group find residence in the TextGenerationFlag property.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Peter2

  • Swamp Rat
  • Posts: 653
Re: How to get entire texstyle info via DBX?
« Reply #13 on: October 29, 2014, 07:30:34 PM »
OK, thanks  :-)

Peter
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How to get entire texstyle info via DBX?
« Reply #14 on: October 29, 2014, 07:47:24 PM »
You're most welcome Peter.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst