I wanted to engrave this in the marble, in order to store this valuable information. I hope this helps
Check Modo Preferences State to avoid bug on different user
I've notice that even if my scripts works well on my end, sometimes (to not say often) people doesn't use the same preferences than yours.
A basic case is when you're using Copy / Paste command in your Python script:
lx.eval('copy') lx.eval('paste')
If you're aware of and have enough experience, you know already that you can get many different combination of behavior via the Modo / Preferences / Defaults / Mesh Items. thoses are set via boolean (true or false)
Deselect Elements after Copying Select Pasted Elements Deselect Elements Before Pasting
I have all those 3 Enable by default. All the Macro 's and Scripts that i've made the past 10 years are impacted by those settings. So it's important to set the same preferences before running a script i made on a different machine.
So down below i have put some checks procedure in 2 parts: One at the start and one at the end of the script.
I hope this will help you sort things up. I will probably add more tips like this in this thread. Share yours here.
Best regards, Franck.
If you want to get more feel free to follow us at Pixelfondue.
1st part: Checking current state, and see if it's needed to get changed.
# Look at current Copy / Paste user Preferences: User_Pref_CopyDeselect = lx.eval('pref.value application.copyDeSelection ?') lx.out('User Pref: Deselect Elements after Copying', User_Pref_CopyDeselect) User_Pref_PasteSelection = lx.eval('pref.value application.pasteSelection ?') lx.out('User Pref: Select Pasted Elements', User_Pref_PasteSelection) User_Pref_PasteDeselect = lx.eval('pref.value application.pasteDeSelection ?') lx.out('User Pref: Deselect Elements Before Pasting', User_Pref_PasteDeselect) # Is Copy Deselect False ? if User_Pref_CopyDeselect == 0: lx.eval('pref.value application.copyDeSelection true') User_Pref_CopyDeselectChangedState = 1
# Is Paste Selection False ? if User_Pref_PasteSelection == 0: lx.eval('pref.value application.pasteSelection true') User_Pref_PasteSelectionChangedState = 1
# Is Paste Deselect False ? if User_Pref_PasteDeselect == 0: lx.eval('pref.value application.pasteDeSelection true') User_Pref_PasteDeselectChangedState = 1
# Is Copy Deselect True ? if User_Pref_CopyDeselect == 1: User_Pref_CopyDeselectChangedState = 0
# Is Paste Selection True ? if User_Pref_PasteSelection == 1: User_Pref_PasteSelectionChangedState = 0
# Is Paste Deselect True ? if User_Pref_PasteDeselect == 1: User_Pref_PasteDeselectChangedState = 0 ################################################
2nd part: At the end of your script put this to Restore the value in case of changed state:
###############COPY/PASTE END Procedure################# # Restore user Preferences: if User_Pref_CopyDeselectChangedState == 1 : lx.eval('pref.value application.copyDeSelection false') lx.out('"Deselect Elements after Copying" have been Restored') if User_Pref_PasteSelectionChangedState == 1 : lx.eval('pref.value application.pasteSelection false') lx.out('"Select Pasted Elements" have been Restored') if User_Pref_PasteDeselectChangedState == 1 : lx.eval('pref.value application.pasteDeSelection false') lx.out('"Deselect Elements Before Pasting" have been Restored') ########################################################
I wanted to engrave this in the marble, in order to store this valuable information. I hope this helps
Check Modo Preferences State to avoid bug on different user
I've notice that even if my scripts works well on my end, sometimes (to not say often) people doesn't use the same preferences than yours.
A basic case is when you're using Copy / Paste command in your Python script:
lx.eval('copy')
lx.eval('paste')
If you're aware of and have enough experience, you know already that you can get many different combination of behavior via the Modo / Preferences / Defaults / Mesh Items. thoses are set via boolean (true or false)
Deselect Elements after Copying
Select Pasted Elements
Deselect Elements Before Pasting
I have all those 3 Enable by default.
All the Macro 's and Scripts that i've made the past 10 years are impacted by those settings.
So it's important to set the same preferences before running a script i made on a different machine.
So down below i have put some checks procedure in 2 parts: One at the start and one at the end of the script.
I hope this will help you sort things up.
I will probably add more tips like this in this thread.
Share yours here.
Best regards, Franck.
If you want to get more feel free to follow us at Pixelfondue.
1st part:
Checking current state, and see if it's needed to get changed.
2nd part:
At the end of your script put this to Restore the value in case of changed state:
https://gumroad.com/smoluck
https://twitter.com/sm0luckedited by: Franck Elisabeth - Smoluck