Tool bar/ribbon or tool palette for Text Styles

Tool bar/ribbon or tool palette for Text Styles

kzD1219
Collaborator Collaborator
1,330 Views
6 Replies
Message 1 of 7

Tool bar/ribbon or tool palette for Text Styles

kzD1219
Collaborator
Collaborator

I have very little knowledge about how to create using macros and lisp, but is there any easy way to create a tool bar or ribbon that contains the 7 text styles that we use.  I want to be able to click it and then have the mtext start at the correct style. I can start a toolbar in the cui dialog box, but is there any where I can drag the text styles on that toolbar/ribbon?  I know the annotate tab has the text panel (civil3d), but I would rather not have the text styles so buried. I included a crude sketch of what I would like to see on the toolbar.

 

In regards to the tool palette, I do know how to grab the text styles and place them on the palette.  Is there any way to make Center Justification the default AND all capitals when the mtext starts?  I have found a macro for justification, but typing the mtext shows up in the command prompt area and not on the drawing itself.  I Would rather have the mtext style come in, justified center, all caps, on the drawing area, not the command prompt.

 

Thanks for any advice.

 

 

0 Likes
1,331 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant

@kzD1219 wrote:

I have very little knowledge about how to create using macros and lisp, but is there any easy way to create a tool bar or ribbon that contains the 7 text styles that we use.  I want to be able to click it and then have the mtext start at the correct style. >> possible, but the best and most simple is using tool palette (which you've said you know how to use)

 

I can start a toolbar in the cui dialog box, but is there any where I can drag the text styles on that toolbar/ribbon? >> it doesn't work like that. you need to create new command (lower left corner of CUI, fill some macro in... macro can call the lisp command)  I know the annotate tab has the text panel (civil3d), but I would rather not have the text styles so buried. >> text-style drop down combo box can be easily copied to Home ribbon - I have it that way  I included a crude sketch of what I would like to see on the toolbar. >> if that would be a toolbar that you need to draw icons with those numbers. If just ribbon tool, you can use text with no image.

 

In regards to the tool palette, I do know how to grab the text styles and place them on the palette.  Is there any way to make Center Justification >> not as easy as setting the tool properties, could be done by macro/lisp, OR you can make from a BLOCK from your text, add it to pallete and then explode it while inserting the default AND all capitals when the mtext starts? >>it's a global thing, if we turn it on for your text, it must be turned off after you're done with the text writing. (LISP can do that) I have found a macro for justification, but typing the mtext shows up in the command prompt area and not on the drawing itself. >>it could be fixed, post the lisp/macro) I Would rather have the mtext style come in, justified center, all caps, on the drawing area, not the command prompt.

 

Thanks for any advice.

 

 


 Here you can try this routine which creates MTEXT, with the style and justification setting, allcaps on.

 

(vl-load-com)

(defun c:MyMtext (/ enl obj)

  (setq enl (entlast))
  (command "_.MTEXT" pause pause "Text" "")
           
  (and (not (equal enl (entlast)))
       (vl-cmdf "_.JUSTIFYTEXT" "_Last" "" "_MC")  	;; mtext justificytion
       (setq obj (vlax-ename->vla-object (entlast)))
       (not (vla-put-stylename obj "Standard"))		;; mtext style
       (not (vla-put-textstring obj ""))
       (setvar 'TEXTALLCAPS 1)
       (not (command-s "_.mtedit" "_L"))
       (setvar 'TEXTALLCAPS 0)				
       )
  (princ)
)

 

0 Likes
Message 3 of 7

Kent1Cooper
Consultant
Consultant

Do you really mean Mtext?  If so, you need to choose between Top Center, Middle Center and Bottom Center justification -- there's no plain Center as there is for plain Text.

 

I can guide you in building a Tool Palette for this, if that will do -- I'm not so much up on ribbon customization.

 

As for the all-capitals part, that can be done by heading outside of AutoCAD, for which I found this a few years back, and I have it in my acaddoc.lsp, so whenever I open a drawing, it's set.  You could put it into a separate command or function definition that could be called in whatever macro you end up with.

 

;; Turn Caps Lock on: [edited from Tim Spangler in "Caps Lock," theswamp.org 04/09/12]
(setq
  isMSW (vlax-get-object "Word.Application"); nil if Word not running already
  MSW (vlax-get-or-create-object "Word.Application"); whether or not already
); setq
(if (= (vlax-get MSW 'CapsLock) 0); Caps Lock is off
  (vlax-invoke-method
    (vla-getInterfaceObject (vlax-get-acad-object) "WScript.Shell")
    'SendKeys "{CAPSLOCK}"
  ); -invoke
); if
(if (not isMSW) (vlax-invoke-method MSW 'quit)); Exit Word only if not otherwise in use
(vlax-release-object MSW)

 

EDIT:  The TEXTALLCAPS System Variable that @ВeekeeCZ suggests is apparently a possibility newer than the routine above, and I hadn't encountered it before.  It's pretty cool, but I find one thing kind of off-putting about it -- it controls it within Text/Mtext inside AutoCAD, but if Caps Lock isn't on outside AutoCAD, the Caps Lock indicator on the keyboard does not turn on.  That means the result is "visually in conflict" with that little light being off.  The above routine does  turn on that indicator, the same as hitting the Caps Lock key.

Kent Cooper, AIA
0 Likes
Message 4 of 7

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... The TEXTALLCAPS System Variable .... I find one thing kind of off-putting about it ....


And another thing, in further usage:  I turned on TEXTALLCAPS, and that works fine to make things All CAPS if I can ignore that the Caps Lock indicator isn't on.  BUT if I am entering or editing content, and do  want some part of it lower-case, the Caps Lock key on the keyboard cannot overcome the TEXTALLCAPS setting.  If I'm editing Mtext, I finally found [in the default-configured 2016 Ribbon] an All CAPS item, in the Tools pull-down underneath the Find & Replace icon [not an obvious place -- one would think that would be Find-&-Replace-related Tools, but it's not].  I can switch it off there, but it has no  visual indication whatever of whether  it's on or off -- no graying out when it's off, no check-mark, no clue appearing at the command line, no nothing.  So I have to continue typing to see whether it changed.  And if I'm editing plain Text, there's no way at all  that I can find to change the setting, except to close out  of editing, change it, and get back in.  And in editing either Text or  Mtext, I cannot use the AutoLISP approach, i.e. (setvar 'textallcaps 0), nor an apostrophe-prefixed transparent 'TEXTALLCAPS "command", from within the Editor.  I can get lower-case by using the Shift key while typing, but it's counter-intuitive to use it to get lower-case instead of upper, and I have to hold it down continuously for all content I want that way.  So as much as I appreciate that the option has been added, I think I will forgo the use of that System Variable.

Kent Cooper, AIA
0 Likes
Message 5 of 7

kzD1219
Collaborator
Collaborator

Great information and I appreciate your time.  I have turned on the ALLCAPS in my mtext so that is what I have as a default.  If I can do the same with all users, they will have all caps too so that fixes that.  I am thinking tools palette will be my easiest option since I have other blocks that I am building within a new palette.  Just don't want to bog down everyone with too many tabs/choices/options.  I was wondering if there was a way with Justification to MC for mtext, but really it isn't that big of a deal.  I do have labels as blocks that when exploded that are justified to the middle center and those are the most important pieces of text.  Thinking that will do.  Just curious of the possibilities.  

0 Likes
Message 6 of 7

ВeekeeCZ
Consultant
Consultant

ok, ALLCAPS solved.

 

for MTEXT create a tool on Tool Palette (not block with mtext then explode)

 

Use properties and change the macro to set justification like this: ^C^C_mtext;\_j;_mc;

 

Your tool properties would look like this:

 

image.png

0 Likes
Message 7 of 7

Kent1Cooper
Consultant
Consultant

Plain Text is a little easier to deal with, since you specify the justification before picking a location, and you don't have to also then pick the second corner of the "box" for Mtext -- one location pick does it.  If that will serve, a macro like this in a Tool Palette item should do it:

 

^C^C-layer _set YourLayerName;;textsize YourTextSize textstyle YourStyleName _.text _mc \0;

 

Omit the textsize setting if the Style has a fixed height.

 

Do you know how to make a new Tool Palette and right-click-drag an object into it to make a basic button?  That would get you to the Layer [so you might omit that from the macro] and Style of the item you dragged, but certain of the options you want won't be set in it, so editing the macro in the Command string slot in its Properties would be needed to add all of that.  Once you do that with one of them, you can Copy/Paste the item to make more of them, rename them and just change the Style names (and heights if not fixed) in each one.

Kent Cooper, AIA
0 Likes