ericwhite@burt
Member
Much like how when quoting someone it is easier to read using the Quote feature, it is a lot easier to understand someones code if they use the built-in BBCode feature. It also takes up less space, and allows seamless copy/paste to and from your text editor.
Its the difference between this:
# --- INPUTS --- #
#--CURRENT FILE DIALOG--#
Win = Windows()
Options1 = []
Options1.append(['File name to modify ', WindowsInputTypes.String, '<File name>'])
Options1.append(['Note: ', WindowsInputTypes.Label, 'Please enter exact filename.' + '\n' + 'Not case sensitive.'])
Options1.append(['Use part in current workspace ', WindowsInputTypes.Boolean, False])
Options1.append(['File is Assembly ', WindowsInputTypes.Boolean, False])
Options1.append(['None', WindowsInputTypes.Label, '\n' 'Press OK to choose file name/location.' + '\n' + 'Press Cancel to exit script.'])
Values = Win.OptionsDialog('Current File?', Options1)
if Values == None:
sys.exit(0)
File_name = Values[0]
#-- ERROR DIALOG --#
if Values[3] == False:
if Values[2] == True:
P = CurrentPart()
else:
try:
P = Part(File_name, False)
except:
Win.ErrorDialog('No file with that name found. Please open file and try again.', 'Error') + sys.exit(0)
else:
if Values[2] == True:
P = CurrentAssembly()
else:
try:
P = Assembly(File_name, False)
except:
Win.ErrorDialog('No file with that name found. Please open file and try again.', 'Error') + sys.exit(0)
And this:
I knew of this from other sites but it took me a minute to find it on this website. Click on the 3 dots in the text editor and you should see a button called " </> Code ".
You can use it by clicking the button then pasting your code, or by surrounding your code with [ CODE ] <insert code> [ /CODE ] (No spaces)
This will make it much easier to read other's code and ensure that you can copy paste it directly into your program and it will be formatted correctly.
Thoughts?
Its the difference between this:
# --- INPUTS --- #
#--CURRENT FILE DIALOG--#
Win = Windows()
Options1 = []
Options1.append(['File name to modify ', WindowsInputTypes.String, '<File name>'])
Options1.append(['Note: ', WindowsInputTypes.Label, 'Please enter exact filename.' + '\n' + 'Not case sensitive.'])
Options1.append(['Use part in current workspace ', WindowsInputTypes.Boolean, False])
Options1.append(['File is Assembly ', WindowsInputTypes.Boolean, False])
Options1.append(['None', WindowsInputTypes.Label, '\n' 'Press OK to choose file name/location.' + '\n' + 'Press Cancel to exit script.'])
Values = Win.OptionsDialog('Current File?', Options1)
if Values == None:
sys.exit(0)
File_name = Values[0]
#-- ERROR DIALOG --#
if Values[3] == False:
if Values[2] == True:
P = CurrentPart()
else:
try:
P = Part(File_name, False)
except:
Win.ErrorDialog('No file with that name found. Please open file and try again.', 'Error') + sys.exit(0)
else:
if Values[2] == True:
P = CurrentAssembly()
else:
try:
P = Assembly(File_name, False)
except:
Win.ErrorDialog('No file with that name found. Please open file and try again.', 'Error') + sys.exit(0)
And this:
Code:
# --- INPUTS --- #
#--CURRENT FILE DIALOG--#
Win = Windows()
Options1 = []
Options1.append(['File name to modify ', WindowsInputTypes.String, '<File name>'])
Options1.append(['Note: ', WindowsInputTypes.Label, 'Please enter exact filename.' + '\n' + 'Not case sensitive.'])
Options1.append(['Use part in current workspace ', WindowsInputTypes.Boolean, False])
Options1.append(['File is Assembly ', WindowsInputTypes.Boolean, False])
Options1.append(['None', WindowsInputTypes.Label, '\n' 'Press OK to choose file name/location.' + '\n' + 'Press Cancel to exit script.'])
Values = Win.OptionsDialog('Current File?', Options1)
if Values == None:
sys.exit(0)
File_name = Values[0]
#-- ERROR DIALOG --#
if Values[3] == False:
if Values[2] == True:
P = CurrentPart()
else:
try:
P = Part(File_name, False)
except:
Win.ErrorDialog('No file with that name found. Please open file and try again.', 'Error') + sys.exit(0)
else:
if Values[2] == True:
P = CurrentAssembly()
else:
try:
P = Assembly(File_name, False)
except:
Win.ErrorDialog('No file with that name found. Please open file and try again.', 'Error') + sys.exit(0)
I knew of this from other sites but it took me a minute to find it on this website. Click on the 3 dots in the text editor and you should see a button called " </> Code ".
You can use it by clicking the button then pasting your code, or by surrounding your code with [ CODE ] <insert code> [ /CODE ] (No spaces)
This will make it much easier to read other's code and ensure that you can copy paste it directly into your program and it will be formatted correctly.
Thoughts?