Hey !
I've made a algoritm but someone can say me if I've some error In my algorithm
And say me if it's possible to export first : the standart Building and after the Destroy building ... thanks for your help !
---------------- DECLARATION DES VARIABLES ----------------------
exportfolderASE = maxfilepath + "ASE\\"
exportfolderGR2 = maxfilepath + "GR2\\"
exportfolder3DS = maxfilepath + "3DS\\"
-- CREATION DES REPERTOIRES S'IL N'EXISTE PAS -----
if doesFileExist exportfolderASE == false do (makedir exportfolderASE)
if doesFileExist exportfolderGR2 == false do (makedir exportfolderGR2)
if doesFileExist exportfolder3DS == false do (makedir exportfolder3DS)
--------------------- DEBUT ALGORITHME -------------------------
try(destroyDialog ::bgaRoll)catch()
rollout bgaRoll "Lunastra Building Compiler • • •"
(
label Help1 "Standard ou détruit ?" align:#center
button btn_delchilds "Standard" align:#center width:100 height:20
button btn_delparents "Détruit" align:#center width:100 height:20
label Help2 "Reset Xform" align:#center
button btn_xform "Reset Xform" align:#center width:100 height:20
label Help3 "Mettez votre modèle droit en vous aidant" align:#center
label Help4 "du repère et de l'outil rotation et cliquez sur Reset Xform" align:#center
label Help5 "En cas de modification du Reset Xform Merci de relancer l'algorithme" align:#center
label Help6 "Copyright by Kasimashi tout droit réservé 2013-2014 ©" align:#center
on btn_delchilds pressed do
(
delete (for o in objects where matchPattern o.name pattern:("*2_*") collect o)
----------------SELECT ALL -----------
Select $*
-------------- ATTACH ALL MESH --------------
(
mtl = #() ; tmp = #() ; fin = #()
sel = selection as array
if sel.count == 0 then -- check selection
messageBox "Erreur lors de l'execution du script s'il vous plait contactez Kasimashi"
else
( -- filter selection
sel = for i in sel where classOf i == Editable_mesh \
and i.material != undefined collect i
if sel.count == 0 then
messageBox "Aucun Mesh dans la séléction !!! " title:"Attacher les Mesh"
else
(
for i in sel do
appendIfUnique mtl i.material
for m in mtl do
(
tmp = for i in sel where i.material == m collect i
append fin tmp
)
undo on
(
for i in fin do
(
trg = i[1]
deleteItem i 1
for j in i do
meshop.attach trg j attachMat:#IDToMat condenseMat:true
)
)
)
)
)
------------------ RENAME MODEL ------------
$.name = "Model"
select $Model
-------------------- WORKING PIVOT + PIVOT ==> RESET XFORM-------------------------
----$ .pivot = [0,0,0]
----workingpivot = [0,0,0]
--resetxform $;
---------------------- PLACE 0;0;0 -----------------
$.pos = [0,0,0]
------------------- SCALE 1/88 FOR FREEWORLD LUNASTRA------------------------
exportFile (exportfolderASE + (getFilenameFile maxFileName)+".ase") #noPrompt
-----------------------EXPORT GR2 + 3DS -----------------------
(
scale $Model [88,88,88]
)
exportFile (exportfolder3DS +(getFilenameFile maxFileName)+".3ds") #noPrompt using:exporterPlugin.classes[1]
exportFile (exportfolderGR2 +(getFilenameFile maxFileName)+".gr2")
-------------------------(RECTIFICATION)--------------------
(
scale $Model [0.0113636363636364,0.0113636363636364,0.0113636363636364]
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
)
)
on btn_delparents pressed do
(
delete (for o in objects where matchPattern o.name pattern:("*2_*") and o.parent != undefined collect o.parent)
----------------SELECT ALL -----------
Select $*
-------------- ATTACH ALL MESH --------------
(
mtl = #() ; tmp = #() ; fin = #()
sel = selection as array
if sel.count == 0 then -- check selection
messageBox "Erreur lors de l'execution du script s'il vous plait contactez Kasimashi"
else
( -- filter selection
sel = for i in sel where classOf i == Editable_mesh \
and i.material != undefined collect i
if sel.count == 0 then
messageBox "Aucun Mesh dans la séléction !!! " title:"Attacher les Mesh"
else
(
for i in sel do
appendIfUnique mtl i.material
for m in mtl do
(
tmp = for i in sel where i.material == m collect i
append fin tmp
)
undo on
(
for i in fin do
(
trg = i[1]
deleteItem i 1
for j in i do
meshop.attach trg j attachMat:#IDToMat condenseMat:true
)
)
)
)
)
------------------ RENAME MODEL ------------
$.name = "Model"
select $Model
-------------------- WORKING PIVOT + PIVOT ==> RESET XFORM-------------------------
----$ .pivot = [0,0,0]
----workingpivot = [0,0,0]
---resetxform $;
---------------------- PLACE 0;0;0 -----------------
$.pos = [0,0,0]
------------------- SCALE 1/88 FOR FREEWORLD LUNASTRA------------------------
exportFile (exportfolderASE + (getFilenameFile maxFileName)+"_destroyed"+".ase") #noPrompt
-----------------------EXPORT GR2 + 3DS -----------------------
(
scale $Model [88,88,88]
)
exportFile (exportfolder3DS +(getFilenameFile maxFileName)+"_destroyed"+".3ds") #noPrompt using:exporterPlugin.classes[1]
exportFile (exportfolderGR2 +(getFilenameFile maxFileName)+"_destroyed"+".gr2")
-------------------------(RECTIFICATION)--------------------
(
scale $Model [0.0113636363636364,0.0113636363636364,0.0113636363636364]
actionMan.executeAction 0 "311" -- Tools: Zoom Extents All Selected
)
)
---------------------- FIN ALGORITHME ---------------------------
on btn_xform pressed do
(
for theNode in selection do if (isValidNode(theNode)) do ResetXForm theNode
)
)
createDialog bgaRoll 350 195 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
By
Comments (3)
Comment policy
Use MAX UNDO
For example:
You can optimize the script.
The exportfolderASE, exportfolderGR2, exportfolder3DS are global in your script. Did you need they to be global? I put them in the rollout, so they are local. Check the Scope of variables in the maxxcript help file for the difference between global and local variables. One of the major rules is to use global variables only when you need them, otherwise use local variables.
:) Thanks for your help !
but how can I scale $Model [88,88,88] and undo to come back with original scale because scale $Model [0.0113636363636364,0.0113636363636364,0.0113636363636364] is not a excact value I want 1/88 scale.
How can I do this ?
Thanks
Kasimashi