Help - keep last used values

Hi guys, how´s going?
i wrote a little script to make extruded faces with chamfered edges, and i was wondering how i could make the last values saved. Because everytime i open the script i need to fill the fields (specially the spinner). Can anyone help me with that? i´m posting an image of the script rollout. I can post the code also if anyone feels that is useful.
Thanks in advance,

Jsrocha

AttachmentSize
chamfer_frame_script.png7.91 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

Here the script, modified by

Here the script, modified by me. :)

AttachmentSize
chamfrollout_ini.ms 4.76 KB
jsrocha's picture

Hi miauu, thanks a lot, it

Hi miauu, thanks a lot, it works perfectly!! I also noticed that you made a lot of improvments and adjustments to my code, i´ll take a look later to try to learn something of it.
Tanks again,

Jsrocha

miauu's picture

adjustments -

adjustments - yes.
improvments - maybe.
:)

miauu's picture

HI, jsrocha!  Later this day

HI, jsrocha!

 Later this day I will have more time and will look at your code. Meanwhile take a look at THIS THREAD. 

 

miauu's picture

Use the INI file to store tha

Use the INI file to store tha last value when user close the script. Then, when the script is started its will read the last value from the ini file. YOu can store the state of the radiobuttons if you wish.

jsrocha's picture

Hey Miauu, thanks for your

Hey Miauu, thanks for your help. I don´t know how to store the last values in this "ini" file, but i´ll try to find out how to do it.
i´m posting the code in another post, just in case you want to take a look.
thanks again,

Jsrocha

Alen's picture

Can you please post the code?

Can you please post the code?

jsrocha's picture

Hi Alen, here is the

Hi Alen, here is the code:

macroScript chamfer_frame
category:"Juliano"
toolTip:""
(
rollout chamfrollout "Chamfer frame" width:162 height:250

(
button botao2 "Chamfro" pos:[69,78] width:84 height:46
spinner xx "espessura" pos:[21,16] width:120 height:16 range:[0,100,3] type:#float
radioButtons sc "chamfro_mm" pos:[23,48] width:29 height:94 labels:#("1", "2", "3", "4", "5")
radioButtons sh "shell mode" pos:[23,150] width:29 height:94 labels:#("both","in","out")
radioButtons chf_side "chamfer side" pos:[23,190] width:29 height:94 labels:#("both","front")

on botao2 pressed do
(
esp = xx.value

(if sc.state == 1 then chamf = 1.0)
(if sc.state == 2 then chamf = 2.0)
(if sc.state == 3 then chamf = 3.0)
(if sc.state == 4 then chamf = 4.0)
(if sc.state == 5 then chamf = 5.0)

(if -- início da condição de inches units
units.SystemType == #inches
then
chamf = chamf / 2.54
)
(if
units.SystemType == #inches
then
esp = esp / 2.54
) -- fim da condição de inches units

(if
sh.state == 1
then
(
modPanel.addModToSelection (Shell ()) ui:on
$.modifiers[#Shell].innerAmount = esp / 2.0 - chamf / 10.0
$.modifiers[#Shell].outerAmount = esp / 2.0 - chamf / 10.0
$.modifiers[#Shell].selectInnerFaces = on
)
)
(if
sh.state == 2
then
(
modPanel.addModToSelection (Shell ()) ui:on
$.modifiers[#Shell].innerAmount = esp - chamf / 5.0
$.modifiers[#Shell].outerAmount = 0
)
)
(if
sh.state == 3
then
(
modPanel.addModToSelection (Shell ()) ui:on
$.modifiers[#Shell].innerAmount = 0
$.modifiers[#Shell].outerAmount = esp - chamf / 5.0
)
)
(if
chf_side.state ==1 -- condição p/ chamfrar em ambos os lados
then
(
$.modifiers[#Shell].selectInnerFaces = on
)
)
(if
chf_side.state ==2 -- condição p/ chamfrar somente na face frontal
then
(
$.modifiers[#Shell].selectInnerFaces = off
)
)

subobjectLevel = 0
$.modifiers[#Shell].selectOuterFaces = on
subobjectLevel = 0
$.modifiers[#Shell].straightenCorners = on
macros.run "Modifiers" "EditPolyMod"
subobjectLevel = 4
$.modifiers[#Edit_Poly].SetOperation #Bevel
$.modifiers[#Edit_Poly].bevelType = 1
$.modifiers[#Edit_Poly].bevelHeight = 0.05 * chamf
$.modifiers[#Edit_Poly].bevelOutline = -0.014 * chamf
$.modifiers[#Edit_Poly].CommitAndRepeat ()
$.modifiers[#Edit_Poly].bevelHeight = 0.036 * chamf
$.modifiers[#Edit_Poly].bevelOutline = -0.036 * chamf
$.modifiers[#Edit_Poly].CommitAndRepeat ()
$.modifiers[#Edit_Poly].bevelHeight = 0.014 * chamf
$.modifiers[#Edit_Poly].bevelOutline = -0.05 * chamf
$.modifiers[#Edit_Poly].Commit ()
subobjectLevel = 0
modPanel.setCurrentObject $.modifiers[#Edit_Poly]
modPanel.addModToSelection (Shell ()) ui:on
$.modifiers[#Shell].innerAmount = 0
$.modifiers[#Shell].selectInnerFaces = off
$.modifiers[#Shell].selectOuterFaces = off
deleteModifier $ 1

)
)
createdialog chamfrollout
)

i´m a poor coder, everything i do is based in studing another people codes, some maxscript help and listener, so please excuse the coding mistakes (must be some of them).
Best regards,

Jsrocha

Alen's picture

Hi, I made some quick

Hi,

I made some quick adjustments which might help you. It keeps the values saved as long as max is active.

I added this to the beginning (before rollout):

if spnValue == undefined then
spnValue=3

changed this line:

spinner xx "espessura" pos:[21,16] width:120 height:16 range:[0,100,spnValue] type:#float

and added:

on botao2 pressed do
(
esp = xx.value
spnValue=xx.value

You can do the same thing for the rest of the controls. If this works for you I can make the necessary edits and send the script back to you.

jsrocha's picture

Hi Alen, thanks a lot. I´ll

Hi Alen, thanks a lot. I´ll study your code to try to use it in this and another codes.
Cheers,

Jsrocha

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.