cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

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

TimSharp
6-Contributor

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

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.

13 REPLIES 13

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.

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.

TimSharp
6-Contributor
(To:thendricks)

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.

Based on your description then, you could write a text element, grab the settings using the element reference, and then change the text settings as desired. Select None when done and then reset your text settings to their originals.

TimSharp
6-Contributor
(To:thendricks)

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.

You are a nice guy. I have to admit. I took the other approach. We basically eliminate personal settings. We need consistent settings for various reasons so each time a user starts their computer all preferences, including toolbar setup, are overwritten.

Why you may ask? Troubleshooting. When we had used Illustrator 10 previous to this each person had their own personalized software in essence. If someone reported a problem I had to dissect things that they set up because we only had one universal tool. Macros were set up by users. They couldn't be shared because they would overwrite each other and everyone wanted something a little different. Needless to say, what you got from one illustrator could vary drastically from the next.

Now I must go back some. I apologize as I mispoke. Some, not all options are readable from an element. The justification can be read and changed using "

element.text.justHor". Font size is still an issue. If you know however the starting font, can't you just set it back to the default by hardcoding the size? Not the best method, but should work unless your illustrators adjust their fonts on their own.

TimSharp
6-Contributor
(To:thendricks)

You are right I am a nice guy 😉

I think you have the right approach.

Here though, we draw to set standards but it's up to each illustrator to achieve those whichever way they want. I am the only person here who knows anything about macros, so I can make sure they are consistent, but I haven't yet started determining people's personal settings.

My new macro that checks how many times macros are used is proving very interesting. I've added a conservative time estimate for savings using each macro (most macros are time savers for drawings tasks we do a lot). The results confirm my inkling that the most productive illustrators are the ones that use the macros the most. I've been running this for nearly 2 weeks and the size of the useage files ranges from 11kb to 129kb. One guy (the 11kb one) refuses to use the CGM macro, insisting on going through the menu process every time!

One good spin off from this is a macro that checks the useage files and extracts the drawing names (de-duping them). We keep Illustration Indexes and tend to fill them in at the end of the day, by which time we've forgotten some of the drawings we've worked on, so this reminds us. It can also be used to check who did a drawing originally, or at least who last edited it. The guy who refuses to use the CGM macro doesn't benefit from this as it's the CGM macro that returns the drawings names.

Regarding your last paragraph. We use the same font throughout, but in a few different sizes, so there's no way of knowing the starting font. Perhaps we should be more structured?

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.....

TimSharp
6-Contributor
(To:Vaduga1)

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.

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

TimSharp
6-Contributor
(To:Vaduga1)

Yes that's what I'm trying to do, but there seem to be some settings that you can't get in Isodraw - you can set the text size, but I haven't found a way yet of fuinding out what the current text size it set to, same for alignment. There are lots orf things you can check but they don't seem to be consistent.

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

TimSharp
6-Contributor
(To:Dutch_Mn)

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.

Top Tags