Jump to content

Recommended Posts

Posted

Hello GUYS :)

 

How are you all ? :D

 

1* how can I get the Name of Text Style and Dimension Style as well .

 

Thankxxxxxxxxxxxx

 

Sweety. :wink:

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • Sweety

    10

  • Lee Mac

    6

  • BlackBox

    6

  • migs

    1

Top Posters In This Topic

Posted

Look in Help for the sysvars Textstyle & Dimstyle

(getvar "...")

Posted (edited)

(getvar 'textstyle)

(getvar 'dimstyle)

 

***for current style's

Edited by Lt Dan's legs
more info
Posted

This will give you the styles for Text and Dimension objects:

 

vla-get-textstyle (Dims only)

vla-get-stylename (Text, Mtext, and Dims)

Posted

Thank you GUYS.

*** AMAAAAAAAAAAAZING ***:lol:

 

1- Thank you Mr.Lt Dan that was useful and direct .:)

2- Thank you Mr. johnM your suggestion is really nice, and I found out that both are the same result.

(tblnext "style" "standard")
((0 . "STYLE") (2 . "Standard") (70 . 0) (40 . 0.0) (41 . 1.0) (50 . 0.0) (71 . 
0) (42 . 0.2) (3 . "ARIAL.TTF") (4 . ""))

(tblsearch "style" "standard")
((0 . "STYLE") (2 . "Standard") (70 . 0) (40 . 0.0) (41 . 1.0) (50 . 0.0) (71 . 
0) (42 . 0.2) (3 . "ARIAL.TTF") (4 . ""))

 

3- :shock: Mr. Renderman This time I couldn't deal with your codes .and I couldn't find them in Help to search

for way of implementing them. So would you please complete them for me ?

 

many many THANKXXXXXXXXXX.

 

Sweety.

Posted (edited)

3- :shock: Mr. Renderman This time I couldn't deal with your codes .and I couldn't find them in Help to search

for way of implementing them. So would you please complete them for me ?

 

Sorry for the confusion. o:)

 

The functions I provided you are for extracting the style information from text and dimension objects within your drawing.

 

For example:

 

If you have text in a drawing from another company, and you want to copy that text into your drawing, but their text style(s) aren't the same as your text style. In this example, let's assume "Standard" is your text style, so we'll look for anything that is "Non-Standard" and replace it...

 

Sample:

(defun c:TEST (/ ss count)
 (vl-load-com)
 (cond
   (*activeDoc*)
   ((setq *activeDoc* (vla-get-activedocument (vlax-get-acad-object)))))
 (prompt "\n  >>  Checking for non-standard text styles... ")
 (if (setq ss (ssget "_x" '((0 . "TEXT,MTEXT") (-4 . "<not") (7 . "Standard") (-4 . "not>"))))
   (progn
     (vlax-for x (setq ss (vla-get-activeselectionset *activeDoc*))
       (vla-put-stylename x "Standard"))
     (prompt
       (strcat "\n<<  "
         (cond
           ((= "1" (setq count (itoa (vla-get-count ss))))
              (strcat count " text object corrected! "))
           ((strcat count " text objects corrected! ")))))
     (vla-delete ss))
   (prompt "\n<<  All text objects have \"standard\" text style "))
 (terpri)
 (princ))

 

 

Edit: You can find more information on these and other VL*- functions inside the VLIDE, using the Apropos button, or look under the ActiveX and VBA Reference in the Developer Documentation

 

Edit: Code revised for accuracy.

 

Hope this helps!

Edited by BlackBox
VL*- reference
Posted

Thank you Renderman for the codes that you provided.

 

And there were some extra brackets and I hope you don't mind as I did remove them.:unsure:

(prompt
       (strcat "\n<<  "
         (cond
           ((= 1 (setq count (itoa (vla-get-count ss))))
              [b][color="red"]([/color][/b]" text object corrected! "[color="red"][b])[/b][/color])
           ((strcat count " text objects corrected! ")))))
     (vla-delete ss)[b][color="red"])[/color][/b]

After that it has worked well. :)

 

BUT. :lol: I haven't seen the codes that you have given in your post No.6 .

 

Thank you for your kindness.

 

Sweety.

Posted

... there were some extra brackets and I hope you don't mind as I did remove them.:unsure:

...

After that it has worked well. :)

...

 

Thank you for the correction. :oops: I guess that's what I get for trying to quickly type out my code from within the text editor, instead of the VLIDE.

 

(setq RM "RenderMan is lazy")

 

 

:lol: I haven't seen the codes that you have given in your post No.6 .

...

 

I had hoped that you could deduce their meaning by the key word differences 'get' instead of 'put', but that's ok.

 

As a quick example of the functions from post #6, try this:

 

(defun c:GETSTYLE  (/ ss objName styleName)
 (vl-load-com)
 (cond
   (*activeDoc*)
   ((setq *activeDoc* (vla-get-activedocument (vlax-get-acad-object)))))
 (prompt "\n  >>  Select dimension or text to list style information: ")
 (if (setq ss (ssget ":S:E" '((0 . "DIMENSION,TEXT,MTEXT"))))
   (progn
     (vlax-for x (setq ss (vla-get-activeselectionset *activeDoc*))
       (alert
         (strcat
           (cond
             ((wcmatch (setq objName (vla-get-objectname x)) "AcDb*Dimension")
                (strcat
                  "Dimension Selected: \n\n"
                  "Text Style =\t"
                  ([color=blue]vla-get-textstyle[/color] x)
                  "\nDim Style  =\t"
                  ([color=blue]vla-get-stylename[/color] x)))
             ((vl-position objName '("AcDbText" "AcDbMText"))
                (strcat
                  "Text Selected: \n\n"
                  "Text Style =\t"
                  ([color=blue]vla-get-stylename[/color] x)))))))
     (vla-delete ss)))
 (princ))

 

 

Does this example make sense for you?

Posted

(setq RM "RenderMan is lazy")

That's a very kind of you, and I did like the way you are using Lisp in life. :lol:

 

Does this example make sense for you?

 

Of course it does. I thank you for great help that you have been giving me.

 

It's greatly appreciated.

 

Sweety.

Posted

Thank you all GUYS.

 

One more question please.

 

How can I get the height of the current text style but not "textsize" .

 

Thanks. :)

Posted

Something like this...

 

In VL:

 

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color] [/b][color=black]GetTextStyleHeight[/color][b][color=black] [/color][/b][b][color=RED]([/color][/b] Style [b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]
 [i][color=#990099];; © Lee Mac 2010[/color][/i]

 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-error-p[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] style
         [b][color=RED]([/color][/b][b][color=BLUE]vl-catch-all-apply[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=BLUE]vla-item[/color][/b]
           [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b]
             [b][color=RED]([/color][/b][b][color=BLUE]vla-get-TextStyles[/color][/b]
               [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b]
                 [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b]
               [b][color=RED])[/color][/b]
             [b][color=RED])[/color][/b]
             style
           [b][color=RED])[/color][/b]
         [b][color=RED])[/color][/b]
       [b][color=RED])[/color][/b]
     [b][color=RED])[/color][/b]
   [b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Height[/color][/b] style[b][color=RED]))[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vla-get-LastHeight[/color][/b] style[b][color=RED])[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Height[/color][/b] style[b][color=RED])[/color][/b]
   [b][color=RED])[/color][/b]
 [b][color=RED])[/color][/b]
[b][color=RED])[/color][/b]

In Vanilla:


[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] [color=black]GetTextStyleHeight[/color] [b][color=RED]([/color][/b] Style [b][color=RED])[/color][/b]
 [i][color=#990099];; © Lee Mac 2010[/color][/i]

 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] style [b][color=RED]([/color][/b][b][color=BLUE]tblsearch[/color][/b] [b][color=#a52a2a]"STYLE"[/color][/b] style[b][color=RED]))[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b]
     [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]zerop[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]assoc[/color][/b] [b][color=#009900]40[/color][/b] style[b][color=RED])))[/color][/b] [b][color=#009900]42[/color][/b] [b][color=#009900]40[/color][/b][b][color=RED])[/color][/b] style
     [b][color=RED])[/color][/b]
   [b][color=RED])[/color][/b]
 [b][color=RED])[/color][/b]
[b][color=RED])[/color][/b]

Posted

I did not get it so far. Lee.

 

Why you are complicating things to me ? :(

 

Thanks

Posted (edited)

LOL! :lol:

 

:: Lee ::

I think what Sweety meant, was that she doesn't understand Visual LISP very well, Lee. I don't think she meant anything by it.

 

:: Sweety ::

Lee's code is much better than my own quick routines, but as an alternative, perhaps these [inferior] routines make more sense to you..?

 

This will tell you the current text style's height:

(defun c:CURTXTHGT ()
 (vl-load-com)
 (prompt
   (strcat
     "\n  <<  Current Text Style Height = "
     (rtos
       (vla-get-height
       (vla-get-activetextstyle
         (cond
           (*activeDoc*)
           ((setq *activeDoc*
                   (vla-get-activedocument
                     (vlax-get-acad-object))))))))
     "  >> "))
 (princ))

 

 

 

Edit:

 

This could be used as a sub-function in another routine:

(defun CURTXTHGT ()
 (vl-load-com)
 (vla-get-height
       (vla-get-activetextstyle
         (cond
           (*activeDoc*)
           ((setq *activeDoc*
                   (vla-get-activedocument
                     (vlax-get-acad-object))))))))

 

 

 

This will show you all the information for the current text style:

(defun c:DUMPCURTXTSTY ()
 (vl-load-com)
 (vlax-dump-object
   (vla-get-activetextstyle
         (cond
           (*activeDoc*)
           ((setq *activeDoc*
                   (vla-get-activedocument
                     (vlax-get-acad-object))))))
   T)
 (textpage)
 (princ))

 

 

Hope this helps!

Edited by BlackBox
Added (vl-load-com)
Posted

Mr. Renderman.

 

You have forgotten to add (vl-load-com).

 

And your routine can not help me as a part to be added to mine. I wonder why.:?

 

Last thing. Should I include that big defun to get only the height of a text style ?

 

Thanks

Posted

Sweety,

 

If you were to use mine, you would call it as a subfunction from your main code, supplying it with the name of the style you wish to query:

 

(GetTextStyleHeight "Standard")

 

It will thus return the height should the style be present.

Posted
Something like this...

(defun GetTextStyleHeight ( Style )

;; © Lee Mac 2010

 

(if (setq style (tblsearch "STYLE" style))

(cdr

(assoc

(if (zerop (cdr (assoc 40 style))) 42 40) style

)

)

)

)

 

Thanks Lee. :D

 

Can you please tell me why did you add Zerop and 42 40 in your codes, although the text can not be zero.

 

Appreciated.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...