FONT EXTRACTION

FONT EXTRACTION

Anonymous
Not applicable
992 Views
3 Replies
Message 1 of 4

FONT EXTRACTION

Anonymous
Not applicable

Hey All,

 

I love this forum - there is so much information to learn and so many experts to learn from...

 

I have howerver, been banging my head on this issue.

 

I am trying to extract a text styles, font, font style and height to a CSV file for examination. And also the dimstyles, text style, font and font style.

 

(defun table (xt / ds tx )
(while (setq ds (tblnext xt (null ds)))
(setq tx (cons (cdr (assoc 2 ds)) tx))
(setq tx (cons (cdr (assoc 100 ds)) tx))
)
)
(table "dimstyle")

 

The DXF code for any DIMTXSTY always seems to be a standard or "" or null output

 


(vlax-for x (vla-get-TextStyles file)
(print (vla-get-Name x))
)

 

This provides a list, nicely.

 

My coding is crap on a  great day. So does any one have a solution or code, to get the actual font, font style and height out to a csv, please?

 

And attempts to get the sma e from a dim results in a requirement to find the block text style...

 

Anyway, cheers ahead of time...

0 Likes
993 Views
3 Replies
Replies (3)
Message 2 of 4

rkmcswain
Mentor
Mentor

Here is something to get you started.

 

(vl-load-com)
(vlax-for x (vla-get-TextStyles
	      (vla-get-activedocument (vlax-get-acad-object))
	    )
  (princ (strcat "\n"
		 (vla-get-Name x)
		 (chr 44)
		 (vla-get-FontFile x)
		 (chr 44)
		 (vl-princ-to-string (vla-get-Height x))
	 )
  )
)

There is no filter to ignore "textstyles" that are actually placeholders for loaded shape files.

There is some sample code here for obtaining TTF properties such as Bold, Italic, etc.

 

 

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 4

hmsilva
Mentor
Mentor

To get the dimensions name, text style and text height, perhaps something like this...

 

(defun c:demo (/ dimstyles)

  (defun dimstyles (/ dimstyle-lst dimstyle-name dimstyle-text-font dimstyle-text-height dimstyle-text-style lst)
    (while (setq dimstyle-lst (tblnext "dimstyle" (null dimstyle-lst)))
      (setq dimstyle-name (cdr (assoc 2 dimstyle-lst))
            dimstyle-text-height (rtos (cdr (assoc 140 dimstyle-lst)) 2 2)
            dimstyle-text-style (entget (cdr (assoc 340 dimstyle-lst)))
            dimstyle-text-font (cdr (assoc 3 dimstyle-text-style))
            lst (cons (list dimstyle-name dimstyle-text-font dimstyle-text-height) lst)
      )
    )
    lst
  )

  (foreach d (dimstyles)
    (princ (strcat "\nDimension style = "
                   (car d)
                   ", dimension text font = "
                   (cadr d)
                   ", dimension text height = "
                   (caddr d)
           )
    )
  )
  (textscr)
  (princ)
)

 

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 4 of 4

Anonymous
Not applicable

Guys,

Thanks a million. I was never going to get to either of those. Totally different approaches to my fumblings.

It's going to take me a while to think about what just happenedand get my head around it.

xx

Boba.

0 Likes