Skip to main content
1-Visitor
March 23, 2011
Question

How can I access current settings and change them back again after a macro?

  • March 23, 2011
  • 4 replies
  • 6075 views

Looking back at some of my older macros I see that in several of them I change things in Isodraw to suit the macro but once the macro is finished, the changed attributes remain, they are not put back to their former state.

For example I have one that adds text to a drawing and sets:

Text size 7
Text align base_line right

Doing this of course leaves the text size at 7 and text align at base_line right regardless of what they were before the macro was run.

What should really be done is to make a variable of the existing text size and alignment settings, so that they can be set back as they were at the end of the macro.

Trouble is I don't know how to extract these values. I'm sure there should be a way, but I can't find it in Macro help.

    4 replies

    12-Amethyst
    March 23, 2011

    What you're requesting could be simple, or it could be difficult. It just depends.

    For your example, it's kind of a loaded question. My suggestion would be to set up a new pen with the settings you desire and the normal pen alone. That way, to switch back, just select the pen you had selected before running the macro (use a variable to capture the pen name before starting the macro).

    This approach could change for things such as controlling a CGM export. You could capture the settings in variables before changing them and then just set them back.

    So, to simplify, or rather not, it depends.

    12-Amethyst
    March 23, 2011

    Another quick note. Remember "Select None". If you start fooling with font stuff and happen to have a text element selected, you'll change that element. So make sure to include a "Select None" statement before changing your fonts.

    TimSharp1-VisitorAuthor
    1-Visitor
    March 23, 2011

    I didn't really want to create new styles.

    We only use 1 text style, just changing the size as required. Similarly for callouts - we just use 1 style and macros to change end dots on or off as required. That way we don't have to keep changing the style as we add callouts, we can just select a group of callouts to change afterwards and click the macro.

    I guess there wouldn't be any problems creating a new style for the macro, but I was hoping there was a way to extract current settings for 'Normal' types so they could be changed for the macro and changed back again afterwards.

    Thanks for the reminder about Select None. We've been using this macro for years without that in, so it's probably caught a few people out - though no-one's said.

    TimSharp1-VisitorAuthor
    1-Visitor
    March 23, 2011

    Yes that's what I want to do, but I don't know where to look that tells me what the current settings are. I know there are some settings that are easily checkable, but for things like text size and alignment, I couldn't find where they can be checked.

    When I used to do CAD programming, we had a macro that saved lots of settings that we'd run at the start of any macro that changed things, then a restore macro at the end to put things back how they were, then we weren't upsetting anyones personal settings.

    1-Visitor
    March 24, 2011

    Hi

    You can create a macro based on editing the preference to current settings and add it at the end of each macro you use.....

    TimSharp1-VisitorAuthor
    1-Visitor
    March 24, 2011

    Yes good, that's what I was trying to do. The problem is I can't find a way to extract the current settings for everything - for example, how do you check what the current text size and alignments are? You can set them OK by just using Text size and Text align, but I haven't found a way of checking their existing settings.

    1-Visitor
    March 25, 2011

    Hi,

    I would like to know whether u would like to retain the Edit----> Prefrence settings (or) pens, layers , line style etc.

    If so you must note each and every setting values from the Preference menu and Layer window and so on.

    Run ur macro.

    Check for what all are the changes made in preference menu after running the macro.

    keeping that changes write macro to change it to ur old preference which u noted.

    I am sorry, without seeing what are all the changes ur macro does, i cannot give a clear reply.

    Thks & Regards

    Vaduga

    1-Visitor
    March 31, 2011

    Here is a real sloppy way to find out a font size.

    We use fonts between sizes between 7 and 24, if I run this it stops on the first font size that matches and I hold that value as (i) until the end of the macro, then at the of the macro I use

    Select if type is equal to text

    Text size i

    Macro Text Size

    Define el as Element

    Define i as integer

    for i = 7 to 24

    Select if Font_size is equal to i if (exists (activeDoc.firstSelectedElement) = False) then

    i = i + 1

    end for

    else

    Message "Font Size is"+i

    End Macro

    TimSharp1-VisitorAuthor
    1-Visitor
    April 8, 2011

    Thanks, that way will at least change the font back to a size that's already used on the current drawing.

    Actually we only tend to use 2 font sizes so I could just set it back to the other font size when the macro's run.

    I would just like to leave things unaffected when my macros run so that people aren't confused when they later re-use something the macro has changed. I'd have thought that as you can set the text size, you'd be able to check what the current size is as well.