Created
October 26, 2015 18:41
-
-
Save JokerMartini/bb49d17769622b28ffca to your computer and use it in GitHub Desktop.
Maxscript: Saves the current 3ds Max scene nodes and various object properties to an XML.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clearlistener() | |
delete objects | |
--// create test scene | |
fn testSceneSetup = | |
( | |
local nodeCount = 100 | |
for i = 1 to nodeCount do | |
( | |
sphere radius:(random 1 10) segs:(random 1 10) | |
) | |
) | |
testSceneSetup() | |
-- Process Log: START | |
t1 = timestamp() | |
m1 = heapfree | |
-- --// Load the xml assemply | |
dotNet.loadAssembly "system.xml" | |
xmlDoc = dotNetObject "system.xml.xmlDocument" | |
/* create header */ | |
header = xmlDoc.CreateXmlDeclaration "1.0" "utf-8" "" | |
xmlDoc.AppendChild header | |
--// Create a root element for the xml doc and add it to the xmlDocument. | |
root = xmlDoc.createElement "Root" | |
xmlDoc.appendChild root | |
--Names for elements can't include anything but alpha characters. | |
for x in objects do | |
( | |
if x.parent==undefined then | |
( | |
--// Create a new element for the object. | |
newElement = xmlDoc.createElement "node" | |
--// Set attributes on the new elements for the name of the object | |
newElement.setAttribute "name" x.name | |
--// Basic Object Properties | |
newElement.setAttribute "wirecolor" (x.wirecolor as string) | |
newElement.setAttribute "isHiddenInVpt" (x.isHiddenInVpt as string) | |
newElement.setAttribute "renderable" (x.renderable as string) | |
newElement.setAttribute "inheritVisibility" (x.inheritVisibility as string) | |
newElement.setAttribute "primaryVisibility" (x.primaryVisibility as string) | |
newElement.setAttribute "secondaryVisibility" (x.secondaryVisibility as string) | |
newElement.setAttribute "receiveShadows" (x.receiveShadows as string) | |
newElement.setAttribute "castShadows" (x.castShadows as string) | |
newElement.setAttribute "applyAtmospherics" (x.applyAtmospherics as string) | |
newElement.setAttribute "renderOccluded" (x.renderOccluded as string) | |
newElement.setAttribute "gbufferChannel" (x.gbufferChannel as string) | |
--Append the new element to the root element. | |
root.appendChild newElement | |
) | |
) | |
--Save the xmlDoc object to a file. | |
xmlDoc.save ((getDir #temp)+"\\test.xml") | |
-- Process Log: END | |
format "time:% memory:%\n" (timestamp() - t1) (m1 - heapfree) | |
--Open the file in Max to see the result. | |
edit ((getDir #temp)+"\\test.xml") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment