Swapped $ for selectedObject, "as string" on value

- $ swap allows for running on multiple objects
- "as string" eases using numeric values (ex: turbosmooth iterations)

function CreateAlembicMetadataModifier selectedObject name value = (

	if selectedObject != undefined then (
		--only allow one modifier
		if selectedObject.modifiers["Alembic Metadata"] == undefined then (

			AlembicMetaDataModifier = EmptyModifier()
			AlembicMetaDataModifier.name = "Alembic Metadata"
			modCount = selectedObject.modifiers.count
			addmodifier selectedObject AlembicMetaDataModifier before:modCount
			selectedObject.modifiers["Alembic Metadata"].enabled = false
		)

		count = custattributes.count selectedObject.modifiers["Alembic Metadata"]
		count = count + 1

		evalstr = "AlembicMetadata = attributes AlembicMetadata\n" +
		"(\n" +
		"	parameters AlembicMetadataPRM1 rollout:AlembicMetadataRLT1\n" +
		"	(\n" +
		"		name type:#string ui:eName default:\"" + name + "\"\n" +
		"		value type:#string ui:eValue default:\"" + (value as string) + "\"\n" +
		"	)\n" +
		"	rollout AlembicMetadataRLT1 \"Alembic Metadata " + (count as string) + "\"\n" +
		"	(\n" +
		"		edittext eName \"n\" fieldWidth:120 labelOnTop:false\n" +
		"		edittext eValue \"v\" fieldWidth:120 labelOnTop:false\n" +
		"	)\n" +
		")"

		AlembicMetadata = execute(evalstr);

		custattributes.add selectedObject.modifiers["Alembic Metadata"] AlembicMetadata baseobject:false

	)
)

function ImportMetadata selectedObject metadataArray = (

	if selectedObject != undefined then
	(
		size = metadataArray.count/2
		a = 1
		for i = 1 to size do
		(
			name = metadataArray[a]
			a = a + 1
			value = metadataArray[a]
			a = a + 1
			CreateAlembicMetadataModifier selectedObject name value
		)

	)
)

---------------------------------------------------------------------------------------------------------
-- MacroScript to link the menu items to MAXScript functions

macroScript AlembicCreateMetadataModifier
    category:"Alembic"
    buttonText:"Add Alembic Metadata..."
    tooltip:"Add Alembic Metadata Display Modifier To Current Selection..."
(
    on execute do
    (
    	for i = 1 to selection.count do
    	(
    		CreateAlembicMetadataModifier selection[i] "" ""
    	)
    )
)

function CreateAlembicMetadataModifier selectedObject name value = (

	if selectedObject != undefined then (
		--only allow one modifier
		if selectedObject.modifiers["Alembic Metadata"] == undefined then (

			AlembicMetaDataModifier = EmptyModifier()
			AlembicMetaDataModifier.name = "Alembic Metadata"
			modCount = $.modifiers.count
			addmodifier selectedObject AlembicMetaDataModifier before:modCount
			selectedObject.modifiers["Alembic Metadata"].enabled = false
		)

		count = custattributes.count selectedObject.modifiers["Alembic Metadata"]
		count = count + 1

		evalstr = "AlembicMetadata = attributes metadata \n" +
		"(\n" +
		"	parameters AlembicMetadataPRM1 rollout:AlembicMetadataRLT1\n" +
		"	(\n" +
		"		_name type:#string ui:eName default:\"" + name + "\"\n" +
		"		_value type:#string ui:eValue default:\"" + value + "\"\n" +
		"	)\n" +
		"	rollout AlembicMetadataRLT1 \"Alembic Metadata " + (count as string) + "\"\n" +
		"	(\n" +
		"		edittext eName \"n\" fieldWidth:120 labelOnTop:false\n" +
		"		edittext eValue \"v\" fieldWidth:120 labelOnTop:false\n" +
		"	)\n" +
		")"

		AlembicMetadata = execute(evalstr);

		custattributes.add selectedObject.modifiers["Alembic Metadata"] AlembicMetadata baseobject:false

	)
)

function ImportMetadata selectedObject metadataArray = (

	if selectedObject != undefined then
	(
		size = metadataArray.count/2
		a = 1
		for i = 1 to size do
		(
			name = metadataArray[a]
			a = a + 1
			value = metadataArray[a]
			a = a + 1
			CreateAlembicMetadataModifier selectedObject name value
		)

	)
)

---------------------------------------------------------------------------------------------------------
-- MacroScript to link the menu items to MAXScript functions

macroScript AlembicCreateMetadataModifier
    category:"Alembic"
    buttonText:"Add Alembic Metadata..."
    tooltip:"Add Alembic Metadata Display Modifier To Current Selection..."
(
    on execute do
    (
    	for i = 1 to selection.count do
    	(
    		CreateAlembicMetadataModifier selection[i] "" ""
    	)
    )
)


fixes #239 "attach to existing" unchecked by default

---------------------------------------------------------------------------------------------------------
-- Custom import/export dialog with settings

rollout AlembicImportSettings "Alembic Import Settings" width:288 height:150
(
    local filename

	GroupBox geoGroup "Geometry" pos:[8,8] width:272 height:104
	checkbox normalCheckbox "Normals" pos:[48,32] width:200 height:15 checked:true
	checkbox uvCheckbox "UVs" pos:[48,48] width:200 height:15 checked:true
    --checkbox clustersCheckbox "Clusters" pos:[48,64] width:200 height:15 checked:true
	checkbox attachCheckbox "Attach to existing objects" pos:[48,64] width:200 height:15 checked:false

	button importButton "Import" pos:[16,120] width:64 height:24
	button cancelButton "Cancel" pos:[208,120] width:64 height:24
	--GroupBox grpVisibility "Visibility" pos:[9,121] width:272 height:46
	--dropdownList dropDownVis "" pos:[20,140] width:252 height:21 items:#("Just Import Value", "Connected Controllers") selection:1
	checkbox materialIdsCheckbox "Material Ids" pos:[48,82] width:145 height:16 checked:true

	on importButton pressed do
	(
	    result = ExocortexAlembic.import filename normalCheckbox.checked uvCheckbox.checked materialIdsCheckbox.checked attachCheckbox.checked 0
	    if( result != 0 ) do
	    (
	    	messageBox "Failure - See Maxscript Listener for details." title:"Exocortex Alembic Import"
	    )
		destroyDialog AlembicImportSettings
	)
	on cancelButton pressed do
	(
	    destroyDialog AlembicImportSettings
	)
)
---------------------------------------------------------------------------------------------------------
-- MAXScript functions to bring up the options dialogs

fn alembicImportDialog =
(
    filename = getOpenFileName caption:"Import from Alembic File:" types:"Alembic(*.abc)|*.abc|All(*.*)|*.*" historyCategory:"Alembic"
    if (filename != undefined) do
    (
        createDialog AlembicImportSettings
        AlembicImportSettings.filename = filename
    )
)

---------------------------------------------------------------------------------------------------------
-- MacroScript to link the menu items to MAXScript functions

macroScript AlembicImportUI
    category:"Alembic"
    buttonText:"Alembic Import..."
    tooltip:"Alembic Import..."
(
    on execute do
    (
        alembicImportDialog()
    )
)

---------------------------------------------------------------------------------------------------------
-- Custom import/export dialog with settings

rollout AlembicImportSettings "Alembic Import Settings" width:288 height:150
(
    local filename

	GroupBox geoGroup "Geometry" pos:[8,8] width:272 height:104
	checkbox normalCheckbox "Normals" pos:[48,32] width:200 height:15 checked:true
	checkbox uvCheckbox "UVs" pos:[48,48] width:200 height:15 checked:true
    --checkbox clustersCheckbox "Clusters" pos:[48,64] width:200 height:15 checked:true
	checkbox attachCheckbox "Attach to existing objects" pos:[48,64] width:200 height:15 checked:true

	button importButton "Import" pos:[16,120] width:64 height:24
	button cancelButton "Cancel" pos:[208,120] width:64 height:24
	--GroupBox grpVisibility "Visibility" pos:[9,121] width:272 height:46
	--dropdownList dropDownVis "" pos:[20,140] width:252 height:21 items:#("Just Import Value", "Connected Controllers") selection:1
	checkbox materialIdsCheckbox "Material Ids" pos:[48,82] width:145 height:16 checked:true

	on importButton pressed do
	(
	    result = ExocortexAlembic.import filename normalCheckbox.checked uvCheckbox.checked materialIdsCheckbox.checked attachCheckbox.checked 0
	    if( result != 0 ) do
	    (
	    	messageBox "Failure - See Maxscript Listener for details." title:"Exocortex Alembic Import"
	    )
		destroyDialog AlembicImportSettings
	)
	on cancelButton pressed do
	(
	    destroyDialog AlembicImportSettings
	)
)
---------------------------------------------------------------------------------------------------------
-- MAXScript functions to bring up the options dialogs

fn alembicImportDialog =
(
    filename = getOpenFileName caption:"Import from Alembic File:" types:"Alembic(*.abc)|*.abc|All(*.*)|*.*" historyCategory:"Alembic"
    if (filename != undefined) do
    (
        createDialog AlembicImportSettings
        AlembicImportSettings.filename = filename
    )
)

---------------------------------------------------------------------------------------------------------
-- MacroScript to link the menu items to MAXScript functions

macroScript AlembicImportUI
    category:"Alembic"
    buttonText:"Alembic Import..."
    tooltip:"Alembic Import..."
(
    on execute do
    (
        alembicImportDialog()
    )
)


fixes #324 -removed deprecated export option

--------------------------------------------------------------------------------------------------------
-- Custom import/export dialog with settings

rollout AlembicExportSettings "Alembic Export Settings" width:288 height:436
(
	GroupBox selectGroup "Selection" pos:[8,16] width:272 height:40
	checkbox exportSelectedCheckbox "Export Selected Objects" pos:[32,32] width:232 height:16 checked:true

	GroupBox animGroup "Animation" pos:[8,64] width:272 height:96
	label inLabel "Frame In" pos:[16,88] width:128 height:21
	label outLabel "Frame Out" pos:[16,104] width:128 height:21
	label stepsLabel "Frame Steps" pos:[16,120] width:128 height:21
	label subStepsLabel "Frame Sub-Steps" pos:[16,136] width:128 height:21
	spinner inSpinner "" pos:[112,88] width:160 height:16 range:[0,1e+006,0] type:#integer
	spinner outSpinner "" pos:[112,104] width:160 height:16 range:[1,1e+006,100] type:#integer
	spinner stepsSpinner "" pos:[112,120] width:160 height:16 range:[1,1e+006,1] type:#integer
	spinner subStepsSpinner "" pos:[112,136] width:160 height:16 range:[1,1e+006,1] type:#integer

	GroupBox geoGroup "Geometry" pos:[8,168] width:272 height:224

	dropdownList meshTopologyDropDown "Mesh Topology" pos:[16,192] width:256 height:40 items:#("Just Surfaces (No Normals)", "Point Cache (No Surfaces)", "Surface + Normals (Everything)") selection:3

	dropdownList particleSystemExportMethod "Particle System Export Method" pos:[16,240] width:256 height:40 items:#("Automatic Instancing", "Merged Mesh") selection:1

	checkbox uvCheckbox "UVs" pos:[32,288] width:128 height:15 checked:true
	checkbox materialIdsCheckbox "Material Ids" pos:[32,320] width:107 height:14 checked:true
	checkbox flattenHierarchyCheckbox "Flatten Hierarchy" pos:[32,336] width:107 height:14 checked:true
	checkbox transformCacheCheckbox "Transform Cache" pos:[32,352] width:200 height:14 checked:false
	checkbox validateMeshTopology "Validate Mesh Topology" pos:[32,368]

	button exportButton "Export" pos:[16,402] width:64 height:24
	button cancelButton "Cancel" pos:[208,402] width:64 height:24

	on exportButton pressed do
	(
	    filename = getSaveFileName caption:"Export to Alembic File:" types:"Alembic(*.abc)|*.abc|All(*.*)|*.*" historyCategory:"Alembic"
	    if (filename != undefined) do
	    (

	    	jobString = "filename=" + (filename as string)
	    	jobString += ";in=" + (inSpinner.value as string)
	    	jobString += ";out=" + (outSpinner.value as string)
	    	jobString += ";step=" + (stepsSpinner.value as string)
	    	jobString += ";substep=" + (subStepsSpinner.value as string)
	    	if(meshTopologyDropDown.selection == 1) do
	    	(
	    		jobString += ";normals=false"
	    		jobString += ";purepointcache=false"
	    	)
	    	if(meshTopologyDropDown.selection == 2) do
	    	(
	    		jobString += ";normals=false"
	    		jobString += ";purepointcache=true"
	    	)
	    	if(meshTopologyDropDown.selection == 3) do
	    	(
	    		jobString += ";purepointcache=false"
	    		jobString += ";normals=true"
	    	)
	    	jobString += ";uvs="
	    	jobString += (uvCheckbox.checked as string)
	    	jobString += ";materialids="
	    	jobString += (materialIdsCheckbox.checked as string)
	    	jobString += ";exportselected="
	    	jobString += (exportSelectedCheckbox.checked as string)
	    	jobString += ";flattenhierarchy="
	    	jobString += (flattenHierarchyCheckbox.checked as string)
	    	if(particleSystemExportMethod.selection == 1) do jobString += ";automaticinstancing=true"
	    	if(particleSystemExportMethod.selection == 2) do jobString += ";particlesystemtomeshconversion=true"
	    	jobString += ";transformCache="
	    	jobString += (transformCacheCheckbox.checked as string)
	    	jobString += ";validateMeshTopology="
	    	jobString += (validateMeshTopology.checked as string)

	    	result = ExocortexAlembic.createExportJobs(jobString)
	        if( result != 0 ) do
	        (
	            	messageBox "Failure - See Maxscript Listener for details." title:"Exocortex Alembic Export"
		    )
	        destroyDialog AlembicExportSettings
	    )
	)
	on cancelButton pressed do
	(
	    destroyDialog AlembicExportSettings
	)

	on AlembicExportSettings open do
    (
		inSpinner.value = animationRange.start
		outSpinner.value = animationRange.end
    )
)
---------------------------------------------------------------------------------------------------------
-- MAXScript functions to bring up the options dialogs

fn alembicExportDialog =
(
    createDialog AlembicExportSettings
)

---------------------------------------------------------------------------------------------------------
-- MacroScript to link the menu items to MAXScript functions

macroScript AlembicExportUI
    category:"Alembic"
    buttonText:"Alembic Export..."
    tooltip:"Alembic Export..."
(
    on execute do
    (
        alembicExportDialog()
    )
)

--------------------------------------------------------------------------------------------------------
-- Custom import/export dialog with settings

rollout AlembicExportSettings "Alembic Export Settings" width:288 height:436
(
	GroupBox selectGroup "Selection" pos:[8,16] width:272 height:40
	checkbox exportSelectedCheckbox "Export Selected Objects" pos:[32,32] width:232 height:16 checked:true

	GroupBox animGroup "Animation" pos:[8,64] width:272 height:96
	label inLabel "Frame In" pos:[16,88] width:128 height:21
	label outLabel "Frame Out" pos:[16,104] width:128 height:21
	label stepsLabel "Frame Steps" pos:[16,120] width:128 height:21
	label subStepsLabel "Frame Sub-Steps" pos:[16,136] width:128 height:21
	spinner inSpinner "" pos:[112,88] width:160 height:16 range:[0,1e+006,0] type:#integer
	spinner outSpinner "" pos:[112,104] width:160 height:16 range:[1,1e+006,100] type:#integer
	spinner stepsSpinner "" pos:[112,120] width:160 height:16 range:[1,1e+006,1] type:#integer
	spinner subStepsSpinner "" pos:[112,136] width:160 height:16 range:[1,1e+006,1] type:#integer

	GroupBox geoGroup "Geometry" pos:[8,168] width:272 height:224

	dropdownList meshTopologyDropDown "Mesh Topology" pos:[16,192] width:256 height:40 items:#("Just Surfaces (No Normals)", "Point Cache (No Surfaces)", "Surface + Normals (Everything)") selection:3

	dropdownList particleSystemExportMethod "Particle System Export Method" pos:[16,240] width:256 height:40 items:#("Automatic Instancing", "Merged Mesh", "Shape Node Instancing (deprecated)") selection:1

	checkbox uvCheckbox "UVs" pos:[32,288] width:128 height:15 checked:true
	checkbox materialIdsCheckbox "Material Ids" pos:[32,320] width:107 height:14 checked:true
	checkbox flattenHierarchyCheckbox "Flatten Hierarchy" pos:[32,336] width:107 height:14 checked:true
	checkbox transformCacheCheckbox "Transform Cache" pos:[32,352] width:200 height:14 checked:false
	checkbox validateMeshTopology "Validate Mesh Topology" pos:[32,368]

	button exportButton "Export" pos:[16,402] width:64 height:24
	button cancelButton "Cancel" pos:[208,402] width:64 height:24

	on exportButton pressed do
	(
	    filename = getSaveFileName caption:"Export to Alembic File:" types:"Alembic(*.abc)|*.abc|All(*.*)|*.*" historyCategory:"Alembic"
	    if (filename != undefined) do
	    (

	    	jobString = "filename=" + (filename as string)
	    	jobString += ";in=" + (inSpinner.value as string)
	    	jobString += ";out=" + (outSpinner.value as string)
	    	jobString += ";step=" + (stepsSpinner.value as string)
	    	jobString += ";substep=" + (subStepsSpinner.value as string)
	    	if(meshTopologyDropDown.selection == 1) do
	    	(
	    		jobString += ";normals=false"
	    		jobString += ";purepointcache=false"
	    	)
	    	if(meshTopologyDropDown.selection == 2) do
	    	(
	    		jobString += ";normals=false"
	    		jobString += ";purepointcache=true"
	    	)
	    	if(meshTopologyDropDown.selection == 3) do
	    	(
	    		jobString += ";purepointcache=false"
	    		jobString += ";normals=true"
	    	)
	    	jobString += ";uvs="
	    	jobString += (uvCheckbox.checked as string)
	    	jobString += ";materialids="
	    	jobString += (materialIdsCheckbox.checked as string)
	    	jobString += ";exportselected="
	    	jobString += (exportSelectedCheckbox.checked as string)
	    	jobString += ";flattenhierarchy="
	    	jobString += (flattenHierarchyCheckbox.checked as string)
	    	if(particleSystemExportMethod.selection == 1) do jobString += ";automaticinstancing=true"
	    	if(particleSystemExportMethod.selection == 2) do jobString += ";particlesystemtomeshconversion=true"
	    	jobString += ";transformCache="
	    	jobString += (transformCacheCheckbox.checked as string)
	    	jobString += ";validateMeshTopology="
	    	jobString += (validateMeshTopology.checked as string)

	    	result = ExocortexAlembic.createExportJobs(jobString)
	        if( result != 0 ) do
	        (
	            	messageBox "Failure - See Maxscript Listener for details." title:"Exocortex Alembic Export"
		    )
	        destroyDialog AlembicExportSettings
	    )
	)
	on cancelButton pressed do
	(
	    destroyDialog AlembicExportSettings
	)

	on AlembicExportSettings open do
    (
		inSpinner.value = animationRange.start
		outSpinner.value = animationRange.end
    )
)
---------------------------------------------------------------------------------------------------------
-- MAXScript functions to bring up the options dialogs

fn alembicExportDialog =
(
    createDialog AlembicExportSettings
)

---------------------------------------------------------------------------------------------------------
-- MacroScript to link the menu items to MAXScript functions

macroScript AlembicExportUI
    category:"Alembic"
    buttonText:"Alembic Export..."
    tooltip:"Alembic Export..."
(
    on execute do
    (
        alembicExportDialog()
    )
)


fixes #276 "Just Surfaces (No Normals)" export option not activated properly

--------------------------------------------------------------------------------------------------------
-- Custom import/export dialog with settings

rollout AlembicExportSettings "Alembic Export Settings" width:288 height:436
(
	GroupBox selectGroup "Selection" pos:[8,16] width:272 height:40
	checkbox exportSelectedCheckbox "Export Selected Objects" pos:[32,32] width:232 height:16 checked:true

	GroupBox animGroup "Animation" pos:[8,64] width:272 height:96
	label inLabel "Frame In" pos:[16,88] width:128 height:21
	label outLabel "Frame Out" pos:[16,104] width:128 height:21
	label stepsLabel "Frame Steps" pos:[16,120] width:128 height:21
	label subStepsLabel "Frame Sub-Steps" pos:[16,136] width:128 height:21
	spinner inSpinner "" pos:[112,88] width:160 height:16 range:[0,1e+006,0] type:#integer
	spinner outSpinner "" pos:[112,104] width:160 height:16 range:[1,1e+006,100] type:#integer
	spinner stepsSpinner "" pos:[112,120] width:160 height:16 range:[1,1e+006,1] type:#integer
	spinner subStepsSpinner "" pos:[112,136] width:160 height:16 range:[1,1e+006,1] type:#integer

	GroupBox geoGroup "Geometry" pos:[8,168] width:272 height:224

	dropdownList meshTopologyDropDown "Mesh Topology" pos:[16,192] width:256 height:40 items:#("Just Surfaces (No Normals)", "Point Cache (No Surfaces)", "Surface + Normals (Everything)") selection:3

	dropdownList particleSystemExportMethod "Particle System Export Method" pos:[16,240] width:256 height:40 items:#("Automatic Instancing", "Merged Mesh", "Shape Node Instancing (deprecated)") selection:1

	checkbox uvCheckbox "UVs" pos:[32,288] width:128 height:15 checked:true
	checkbox materialIdsCheckbox "Material Ids" pos:[32,320] width:107 height:14 checked:true
	checkbox flattenHierarchyCheckbox "Flatten Hierarchy" pos:[32,336] width:107 height:14 checked:true
	checkbox transformCacheCheckbox "Transform Cache" pos:[32,352] width:200 height:14 checked:false
	checkbox validateMeshTopology "Validate Mesh Topology" pos:[32,368]

	button exportButton "Export" pos:[16,402] width:64 height:24
	button cancelButton "Cancel" pos:[208,402] width:64 height:24

	on exportButton pressed do
	(
	    filename = getSaveFileName caption:"Export to Alembic File:" types:"Alembic(*.abc)|*.abc|All(*.*)|*.*" historyCategory:"Alembic"
	    if (filename != undefined) do
	    (

	    	jobString = "filename=" + (filename as string)
	    	jobString += ";in=" + (inSpinner.value as string)
	    	jobString += ";out=" + (outSpinner.value as string)
	    	jobString += ";step=" + (stepsSpinner.value as string)
	    	jobString += ";substep=" + (subStepsSpinner.value as string)
	    	if(meshTopologyDropDown.selection == 1) do
	    	(
	    		jobString += ";normals=false"
	    		jobString += ";purepointcache=false"
	    	)
	    	if(meshTopologyDropDown.selection == 2) do
	    	(
	    		jobString += ";normals=false"
	    		jobString += ";purepointcache=true"
	    	)
	    	if(meshTopologyDropDown.selection == 3) do
	    	(
	    		jobString += ";purepointcache=false"
	    		jobString += ";normals=true"
	    	)
	    	jobString += ";uvs="
	    	jobString += (uvCheckbox.checked as string)
	    	jobString += ";materialids="
	    	jobString += (materialIdsCheckbox.checked as string)
	    	jobString += ";exportselected="
	    	jobString += (exportSelectedCheckbox.checked as string)
	    	jobString += ";flattenhierarchy="
	    	jobString += (flattenHierarchyCheckbox.checked as string)
	    	if(particleSystemExportMethod.selection == 1) do jobString += ";automaticinstancing=true"
	    	if(particleSystemExportMethod.selection == 2) do jobString += ";particlesystemtomeshconversion=true"
	    	jobString += ";transformCache="
	    	jobString += (transformCacheCheckbox.checked as string)
	    	jobString += ";validateMeshTopology="
	    	jobString += (validateMeshTopology.checked as string)

	    	result = ExocortexAlembic.createExportJobs(jobString)
	        if( result != 0 ) do
	        (
	            	messageBox "Failure - See Maxscript Listener for details." title:"Exocortex Alembic Export"
		    )
	        destroyDialog AlembicExportSettings
	    )
	)
	on cancelButton pressed do
	(
	    destroyDialog AlembicExportSettings
	)

	on AlembicExportSettings open do
    (
		inSpinner.value = animationRange.start
		outSpinner.value = animationRange.end
    )
)
---------------------------------------------------------------------------------------------------------
-- MAXScript functions to bring up the options dialogs

fn alembicExportDialog =
(
    createDialog AlembicExportSettings
)

---------------------------------------------------------------------------------------------------------
-- MacroScript to link the menu items to MAXScript functions

macroScript AlembicExportUI
    category:"Alembic"
    buttonText:"Alembic Export..."
    tooltip:"Alembic Export..."
(
    on execute do
    (
        alembicExportDialog()
    )
)

--------------------------------------------------------------------------------------------------------
-- Custom import/export dialog with settings

rollout AlembicExportSettings "Alembic Export Settings" width:288 height:436
(
	GroupBox selectGroup "Selection" pos:[8,16] width:272 height:40
	checkbox exportSelectedCheckbox "Export Selected Objects" pos:[32,32] width:232 height:16 checked:true

	GroupBox animGroup "Animation" pos:[8,64] width:272 height:96
	label inLabel "Frame In" pos:[16,88] width:128 height:21
	label outLabel "Frame Out" pos:[16,104] width:128 height:21
	label stepsLabel "Frame Steps" pos:[16,120] width:128 height:21
	label subStepsLabel "Frame Sub-Steps" pos:[16,136] width:128 height:21
	spinner inSpinner "" pos:[112,88] width:160 height:16 range:[0,1e+006,0] type:#integer
	spinner outSpinner "" pos:[112,104] width:160 height:16 range:[1,1e+006,100] type:#integer
	spinner stepsSpinner "" pos:[112,120] width:160 height:16 range:[1,1e+006,1] type:#integer
	spinner subStepsSpinner "" pos:[112,136] width:160 height:16 range:[1,1e+006,1] type:#integer

	GroupBox geoGroup "Geometry" pos:[8,168] width:272 height:224

	dropdownList meshTopologyDropDown "Mesh Topology" pos:[16,192] width:256 height:40 items:#("Just Surfaces (No Normals)", "Point Cache (No Surfaces)", "Surface + Normals (Everything)") selection:3

	dropdownList particleSystemExportMethod "Particle System Export Method" pos:[16,240] width:256 height:40 items:#("Automatic Instancing", "Merged Mesh", "Shape Node Instancing (deprecated)") selection:1

	checkbox uvCheckbox "UVs" pos:[32,288] width:128 height:15 checked:true
	checkbox materialIdsCheckbox "Material Ids" pos:[32,320] width:107 height:14 checked:true
	checkbox flattenHierarchyCheckbox "Flatten Hierarchy" pos:[32,336] width:107 height:14 checked:true
	checkbox transformCacheCheckbox "Transform Cache" pos:[32,352] width:200 height:14 checked:false
	checkbox validateMeshTopology "Validate Mesh Topology" pos:[32,368]

	button exportButton "Export" pos:[16,402] width:64 height:24
	button cancelButton "Cancel" pos:[208,402] width:64 height:24

	on exportButton pressed do
	(
	    filename = getSaveFileName caption:"Export to Alembic File:" types:"Alembic(*.abc)|*.abc|All(*.*)|*.*" historyCategory:"Alembic"
	    if (filename != undefined) do
	    (

	    	jobString = "filename=" + (filename as string)
	    	jobString += ";in=" + (inSpinner.value as string)
	    	jobString += ";out=" + (outSpinner.value as string)
	    	jobString += ";step=" + (stepsSpinner.value as string)
	    	jobString += ";substep=" + (subStepsSpinner.value as string)
	    	if(meshTopologyDropDown.selection == 2) do jobString += ";purepointcache=true"
	    	if(meshTopologyDropDown.selection == 3) do jobString += ";normals=true"
	    	jobString += ";uvs="
	    	jobString += (uvCheckbox.checked as string)
	    	jobString += ";materialids="
	    	jobString += (materialIdsCheckbox.checked as string)
	    	jobString += ";exportselected="
	    	jobString += (exportSelectedCheckbox.checked as string)
	    	jobString += ";flattenhierarchy="
	    	jobString += (flattenHierarchyCheckbox.checked as string)
	    	if(particleSystemExportMethod.selection == 1) do jobString += ";automaticinstancing=true"
	    	if(particleSystemExportMethod.selection == 2) do jobString += ";particlesystemtomeshconversion=true"
	    	jobString += ";transformCache="
	    	jobString += (transformCacheCheckbox.checked as string)
	    	jobString += ";validateMeshTopology="
	    	jobString += (validateMeshTopology.checked as string)

	    	result = ExocortexAlembic.createExportJobs(jobString)
	        if( result != 0 ) do
	        (
	            	messageBox "Failure - See Maxscript Listener for details." title:"Exocortex Alembic Export"
		    )
	        destroyDialog AlembicExportSettings
	    )
	)
	on cancelButton pressed do
	(
	    destroyDialog AlembicExportSettings
	)

	on AlembicExportSettings open do
    (
		inSpinner.value = animationRange.start
		outSpinner.value = animationRange.end
    )
)
---------------------------------------------------------------------------------------------------------
-- MAXScript functions to bring up the options dialogs

fn alembicExportDialog =
(
    createDialog AlembicExportSettings
)

---------------------------------------------------------------------------------------------------------
-- MacroScript to link the menu items to MAXScript functions

macroScript AlembicExportUI
    category:"Alembic"
    buttonText:"Alembic Export..."
    tooltip:"Alembic Export..."
(
    on execute do
    (
        alembicExportDialog()
    )
)


Updated Script date

Updated Script date

-------------------------------------------------------------------------------
-- PixGrinder.mcr
-- MacroScripts File
-- By Philippe DASSONVILLE ( pixgrinder@gmail.com )
-- 05/04/2016
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
(

	macroScript AutoSavePixGrinder
	category:"-- PixGrinder --"
	toolTip:"AutoSave - PixGrinder"
	buttonText:"AutoSave - PixGrinder"
	icon:#("FileLinkActionItems",9)
	silentErrors:false
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/AutoSave_PixGrinder.ms"
	)

	macroScript BboxTrueMaker
	category:"-- PixGrinder --"
	toolTip:"Bbox True Maker"
	buttonText:"Bbox True Maker"
	--icon:#("FileLinkActionItems",9)
	silentErrors:false
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Bbox_TrueMaker.ms"
	)

	macroScript NamesTransfer
	category:"-- PixGrinder --"
	toolTip:"Names Transfert"
	buttonText:"NamesTransfer"
	--icon:#("FileLinkActionItems",9)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/NamesTransfer.ms"
	)

	macroScript Collapse_Selected
	category:"-- PixGrinder --"
	toolTip:"Collapse Hierarchy on Selection"
	buttonText:"Collapse Selected"
	icon:#("PixGrinder",1)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Collapse.mse"
	)

	macroScript ResetXForm
	category:"-- PixGrinder --"
	toolTip:"ResetXForm on Selection"
	buttonText:"ResetXForm"
	icon:#("PixGrinder",4)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/ResetXform.mse"
	)

	macroScript Select_Previous_Object
	category:"-- PixGrinder --"
	toolTip:"Select Previous Object"
	buttonText:"Select Previous Object"
	icon:#("PixGrinder",3)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Select_Prev_v6.ms"
	)

	macroScript Select_Next_Object
	category:"-- PixGrinder --"
	toolTip:"Select Next Object"
	buttonText:"Select Next Object"
	icon:#("PixGrinder",2)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Select_Next_v6.ms"
	)

	macroScript Duplicator
	category:"-- PixGrinder --"
	toolTip:"Duplicator"
	buttonText:"Duplicator"
	icon:#("PixGrinder",15)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Duplicator_v2.mse"
	)

	macroScript Select_Hierarcy
	category:"-- PixGrinder --"
	toolTip:"Select Hierarchy"
	buttonText:"Select Hierarchy"
	icon:#("PixGrinder",16)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Select_Hierarchy.mse"
	)

	macroScript Rotation_Activator
	category:"-- PixGrinder --"
	toolTip:"Rotation_Activator"
	buttonText:"Rotation_Activator"
	icon:#("FileLinkActionItems",1)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Rotation_Activator.mse"
	)

	macroScript CleanLayers
	category:"-- PixGrinder --"
	toolTip:"Clean Layers"
	buttonText:"Clean Layers"
	icon:#("PixGrinder",8)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/CleanLayers_v2.ms"
	)

	macroScript AssignCurrentMaterial
	category:"-- PixGrinder --"
	toolTip:"Assign Current Material"
	buttonText:"Assign Current Material"
	icon:#("PixGrinder",19)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/AssignCurrentMaterial.ms"
	)

	macroScript FaceMode
	category:"-- PixGrinder --"
	toolTip:"FaceMode - PixGrinder"
	buttonText:"FaceMode"
	icon:#("EditMesh",4)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/FaceMode_v2.ms"
	)

	macroScript ShapeSelectOptimizer
	category:"-- PixGrinder --"
	toolTip:"ShapeSelectOptimizer - PixGrinder"
	buttonText:"ShapeSelectOptimizer"
	icon:#("bip_curve",5)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/ShapeSelectOptimizer_v1.ms"
	)

	macroScript LayersViewToggle
	category:"-- PixGrinder --"
	toolTip:"Layers View Toggle - PixGrinder"
	buttonText:"Layers View Toggle"
	icon:#("AnimLayerToolbar",11)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Layers_view_Toggle_v2.ms"
	)

	macroScript LayersFreezeToggle
	category:"-- PixGrinder --"
	toolTip:"Layers Freeze Toggle - PixGrinder"
	buttonText:"Layers Freeze Toggle"
	icon:#("TrackViewTools",115)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Layers_freeze_Toggle_v2.ms"
	)

	macroScript CableRetopology
	category:"-- PixGrinder --"
	toolTip:"Cable Retopology - PixGrinder"
	buttonText:"CableRetopology"
	icon:#("Splines",11)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Cable_Retopology.ms"
	)

	macroScript LocksToggler
	category:"-- PixGrinder --"
	toolTip:"Toggles Transforms locks"
	buttonText:"Animation Locks Toggler"
	icon:#("SnapsControls",1)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/LocksToggler_V1.ms"
	)

	macroScript TrisToQuad
	category:"-- PixGrinder --"
	toolTip:"Triangle To Quads"
	buttonText:"TrisToQuad"
	icon:#("EditMesh",2)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/polyquad2.ms"
	)

	macroScript PivotCenter
	category:"-- PixGrinder --"
	toolTip:"PivotCenter"
	buttonText:"PivotCenter"
	icon:#("Maintoolbar",33)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Pivot_Center.ms"
	)

	macroScript PivotPerObject
	category:"-- PixGrinder --"
	toolTip:"PivotPerObject"
	buttonText:"PivotPerObject"
	icon:#("Maintoolbar",31)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Pivot_PerObject.ms"
	)

	macroScript PivotExternal
	category:"-- PixGrinder --"
	toolTip:"PivotExternal"
	buttonText:"PivotExternal"
	icon:#("Maintoolbar",35)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Pivot_External.ms"
	)

	macroScript WireColorChanger
	category:"-- PixGrinder --"
	toolTip:"Wire Color Changer"
	buttonText:"Wire Color Changer"
	icon:#("Material_Modifiers",3)
	silentErrors:false
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/WireColorChanger_v2.ms"
	)

	macroScript PivotAlignator
	category:"-- PixGrinder --"
	toolTip:"Pivot Alignator"
	buttonText:"PivotAlignator"
	icon:#("Helpers",1)
	silentErrors:false
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Pivot_Alignator_V3.ms"
	)

	macroScript MaterialRemove
	category:"-- PixGrinder --"
	toolTip:"Material Remove"
	buttonText:"Material Remove"
	icon:#("UVWUnwrapOption",2)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/MaterialRemove.ms"
	)

	macroScript SearchByName
	category:"-- PixGrinder --"
	toolTip:"SearchByName"
	buttonText:"Srch"
	icon:#("Maxscript",2)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/search_by_Name.ms"
	)

	macroScript LayerFromSelection
	category:"-- PixGrinder --"
	toolTip:"Layer Isolate Objects's layer"
	buttonText:"Layer Isolate Objects's layer"
	icon:#("AnimLayerToolbar",4)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/LayerShowFromSelec.ms"
	)

	macroScript SymY
	category:"-- PixGrinder --"
	toolTip:"Symmetry on Y"
	buttonText:"Symmetry on Y"
	icon:#("UVWUnwrapTools",42)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Symetry_Y_v1.ms"
	)

	macroScript XRefMulti
	category:"-- PixGrinder --"
	toolTip:"Xref multiple max files on the fly !"
	buttonText:"XRefMulti"
	-- icon:#("UVWUnwrapTools",42)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/XrefScene_multi.ms"
	)

	macroScript BS_CollapseMultiMaterial
	category:"-- PixGrinder --"
	toolTip:"Collapse MultiSubObjects Material"
	buttonText:"Collapse MultiMat"
	icon:#("BlurScripts",51)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Blur_CollapseSubObjectMaterial_v1.ms"
	)

	macroScript Reveal_MaxFile
	category:"-- PixGrinder --"
	toolTip:"Reveal Current Scene in Windows Explorer"
	buttonText:"Reveal Scene..."
	--icon:#("BlurScripts",51)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Reveal_Maxfile_In_Explorer.ms"
	)

	macroScript MaxScript_Help
	category:"-- PixGrinder --"
	toolTip:"MaxScript Help Offline"
	buttonText:"MaxScript Help Offline"
	icon:#("MaxScript",5)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/MaxScript_Offline_Help.ms"
	)

	macroScript AssetsFinder
	category:"-- PixGrinder --"
	toolTip:"AssetsFinder"
	buttonText:"Search..."
	icon:#("Maxscript",2)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Assets_Finder.ms"
	)

	macroScript CustAttribTransfer
	category:"-- PixGrinder --"
	toolTip:"Transfer Custom Attribs"
	buttonText:"AttribTransfer"
	--icon:#("Maxscript",2)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/CustAttribTransfer.ms"
	)

	macroScript BitmapFuckingUpdate
	category:"-- PixGrinder --"
	toolTip:"Bitmap Force Update !!"
	buttonText:"Bitmap Force Update"
	icon:#("PixGrinder",20)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/BitmapFuckingUpdate.ms"
	)

	macroScript SplineSelectMiddlePoints
	category:"-- PixGrinder --"
	toolTip:"Selects Middle points on a Spline"
	buttonText:"SplinePoints"
	icon:#("Splines",3)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/SplineSelectMiddlePoints.ms"
	)

	macroScript RefPlaneAutoRatio
	category:"-- PixGrinder --"
	toolTip:"Adjust Reference plane to its bitmap"
	buttonText:"Ref Plane AutoRatio"
	-- icon:#("Splines",3)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Ref_Plane_AutoRatio.ms"
	)

	macroScript SelectSmallObjects
	category:"-- PixGrinder --"
	toolTip:"Select small objects"
	buttonText:"Select small objects"
	-- icon:#("Splines",3)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Select_Small_Objects.ms"
	)

	macroScript CornerVertex
	category:"-- PixGrinder --"
	toolTip:"Corner"
	buttonText:"Corner"
	-- icon:#("Splines",3)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Corner_Vertex.ms"
	)

)

-------------------------------------------------------------------------------
-- PixGrinder.mcr
-- MacroScripts File
-- By Philippe DASSONVILLE ( pixgrinder@gmail.com )
-- 28/01/2016
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
(

	macroScript AutoSavePixGrinder
	category:"-- PixGrinder --"
	toolTip:"AutoSave - PixGrinder"
	buttonText:"AutoSave - PixGrinder"
	icon:#("FileLinkActionItems",9)
	silentErrors:false
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/AutoSave_PixGrinder.ms"
	)

	macroScript BboxTrueMaker
	category:"-- PixGrinder --"
	toolTip:"Bbox True Maker"
	buttonText:"Bbox True Maker"
	--icon:#("FileLinkActionItems",9)
	silentErrors:false
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Bbox_TrueMaker.ms"
	)

	macroScript NamesTransfer
	category:"-- PixGrinder --"
	toolTip:"Names Transfert"
	buttonText:"NamesTransfer"
	--icon:#("FileLinkActionItems",9)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/NamesTransfer.ms"
	)

	macroScript Collapse_Selected
	category:"-- PixGrinder --"
	toolTip:"Collapse Hierarchy on Selection"
	buttonText:"Collapse Selected"
	icon:#("PixGrinder",1)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Collapse.mse"
	)

	macroScript ResetXForm
	category:"-- PixGrinder --"
	toolTip:"ResetXForm on Selection"
	buttonText:"ResetXForm"
	icon:#("PixGrinder",4)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/ResetXform.mse"
	)

	macroScript Select_Previous_Object
	category:"-- PixGrinder --"
	toolTip:"Select Previous Object"
	buttonText:"Select Previous Object"
	icon:#("PixGrinder",3)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Select_Prev_v6.ms"
	)

	macroScript Select_Next_Object
	category:"-- PixGrinder --"
	toolTip:"Select Next Object"
	buttonText:"Select Next Object"
	icon:#("PixGrinder",2)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Select_Next_v6.ms"
	)

	macroScript Duplicator
	category:"-- PixGrinder --"
	toolTip:"Duplicator"
	buttonText:"Duplicator"
	icon:#("PixGrinder",15)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Duplicator_v2.mse"
	)

	macroScript Select_Hierarcy
	category:"-- PixGrinder --"
	toolTip:"Select Hierarchy"
	buttonText:"Select Hierarchy"
	icon:#("PixGrinder",16)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Select_Hierarchy.mse"
	)

	macroScript Rotation_Activator
	category:"-- PixGrinder --"
	toolTip:"Rotation_Activator"
	buttonText:"Rotation_Activator"
	icon:#("FileLinkActionItems",1)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Rotation_Activator.mse"
	)

	macroScript CleanLayers
	category:"-- PixGrinder --"
	toolTip:"Clean Layers"
	buttonText:"Clean Layers"
	icon:#("PixGrinder",8)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/CleanLayers_v2.ms"
	)

	macroScript AssignCurrentMaterial
	category:"-- PixGrinder --"
	toolTip:"Assign Current Material"
	buttonText:"Assign Current Material"
	icon:#("PixGrinder",19)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/AssignCurrentMaterial.ms"
	)

	macroScript FaceMode
	category:"-- PixGrinder --"
	toolTip:"FaceMode - PixGrinder"
	buttonText:"FaceMode"
	icon:#("EditMesh",4)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/FaceMode_v2.ms"
	)

	macroScript ShapeSelectOptimizer
	category:"-- PixGrinder --"
	toolTip:"ShapeSelectOptimizer - PixGrinder"
	buttonText:"ShapeSelectOptimizer"
	icon:#("bip_curve",5)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/ShapeSelectOptimizer_v1.ms"
	)

	macroScript LayersViewToggle
	category:"-- PixGrinder --"
	toolTip:"Layers View Toggle - PixGrinder"
	buttonText:"Layers View Toggle"
	icon:#("AnimLayerToolbar",11)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Layers_view_Toggle_v2.ms"
	)

	macroScript LayersFreezeToggle
	category:"-- PixGrinder --"
	toolTip:"Layers Freeze Toggle - PixGrinder"
	buttonText:"Layers Freeze Toggle"
	icon:#("TrackViewTools",115)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Layers_freeze_Toggle_v2.ms"
	)

	macroScript CableRetopology
	category:"-- PixGrinder --"
	toolTip:"Cable Retopology - PixGrinder"
	buttonText:"CableRetopology"
	icon:#("Splines",11)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Cable_Retopology.ms"
	)

	macroScript LocksToggler
	category:"-- PixGrinder --"
	toolTip:"Toggles Transforms locks"
	buttonText:"Animation Locks Toggler"
	icon:#("SnapsControls",1)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/LocksToggler_V1.ms"
	)

	macroScript TrisToQuad
	category:"-- PixGrinder --"
	toolTip:"Triangle To Quads"
	buttonText:"TrisToQuad"
	icon:#("EditMesh",2)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/polyquad2.ms"
	)

	macroScript PivotCenter
	category:"-- PixGrinder --"
	toolTip:"PivotCenter"
	buttonText:"PivotCenter"
	icon:#("Maintoolbar",33)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Pivot_Center.ms"
	)

	macroScript PivotPerObject
	category:"-- PixGrinder --"
	toolTip:"PivotPerObject"
	buttonText:"PivotPerObject"
	icon:#("Maintoolbar",31)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Pivot_PerObject.ms"
	)

	macroScript PivotExternal
	category:"-- PixGrinder --"
	toolTip:"PivotExternal"
	buttonText:"PivotExternal"
	icon:#("Maintoolbar",35)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Pivot_External.ms"
	)

	macroScript WireColorChanger
	category:"-- PixGrinder --"
	toolTip:"Wire Color Changer"
	buttonText:"Wire Color Changer"
	icon:#("Material_Modifiers",3)
	silentErrors:false
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/WireColorChanger_v2.ms"
	)

	macroScript PivotAlignator
	category:"-- PixGrinder --"
	toolTip:"Pivot Alignator"
	buttonText:"PivotAlignator"
	icon:#("Helpers",1)
	silentErrors:false
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Pivot_Alignator_V3.ms"
	)

	macroScript MaterialRemove
	category:"-- PixGrinder --"
	toolTip:"Material Remove"
	buttonText:"Material Remove"
	icon:#("UVWUnwrapOption",2)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/MaterialRemove.ms"
	)

	macroScript SearchByName
	category:"-- PixGrinder --"
	toolTip:"SearchByName"
	buttonText:"Srch"
	icon:#("Maxscript",2)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/search_by_Name.ms"
	)

	macroScript LayerFromSelection
	category:"-- PixGrinder --"
	toolTip:"Layer Isolate Objects's layer"
	buttonText:"Layer Isolate Objects's layer"
	icon:#("AnimLayerToolbar",4)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/LayerShowFromSelec.ms"
	)

	macroScript SymY
	category:"-- PixGrinder --"
	toolTip:"Symmetry on Y"
	buttonText:"Symmetry on Y"
	icon:#("UVWUnwrapTools",42)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Symetry_Y_v1.ms"
	)

	macroScript XRefMulti
	category:"-- PixGrinder --"
	toolTip:"Xref multiple max files on the fly !"
	buttonText:"XRefMulti"
	-- icon:#("UVWUnwrapTools",42)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/XrefScene_multi.ms"
	)

	macroScript BS_CollapseMultiMaterial
	category:"-- PixGrinder --"
	toolTip:"Collapse MultiSubObjects Material"
	buttonText:"Collapse MultiMat"
	icon:#("BlurScripts",51)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Blur_CollapseSubObjectMaterial_v1.ms"
	)

	macroScript Reveal_MaxFile
	category:"-- PixGrinder --"
	toolTip:"Reveal Current Scene in Windows Explorer"
	buttonText:"Reveal Scene..."
	--icon:#("BlurScripts",51)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Reveal_Maxfile_In_Explorer.ms"
	)

	macroScript MaxScript_Help
	category:"-- PixGrinder --"
	toolTip:"MaxScript Help Offline"
	buttonText:"MaxScript Help Offline"
	icon:#("MaxScript",5)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/MaxScript_Offline_Help.ms"
	)

	macroScript AssetsFinder
	category:"-- PixGrinder --"
	toolTip:"AssetsFinder"
	buttonText:"Search..."
	icon:#("Maxscript",2)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/Assets_Finder.ms"
	)

	macroScript CustAttribTransfer
	category:"-- PixGrinder --"
	toolTip:"Transfer Custom Attribs"
	buttonText:"AttribTransfer"
	--icon:#("Maxscript",2)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/CustAttribTransfer.ms"
	)

	macroScript BitmapFuckingUpdate
	category:"-- PixGrinder --"
	toolTip:"Bitmap Force Update !!"
	buttonText:"Bitmap Force Update"
	icon:#("PixGrinder",20)
	silentErrors:true
	autoUndoEnabled:false
	(
		Include "$userScripts/PixGrinder/BitmapFuckingUpdate.ms"
	)

	macroScript SplineSelectMiddlePoints
	category:"-- PixGrinder --"
	toolTip:"Selects Middle points on a Spline"
	buttonText:"SplinePoints"
	icon:#("Splines",3)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/SplineSelectMiddlePoints.ms"
	)

	macroScript RefPlaneAutoRatio
	category:"-- PixGrinder --"
	toolTip:"Adjust Reference plane to its bitmap"
	buttonText:"Ref Plane AutoRatio"
	-- icon:#("Splines",3)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Ref_Plane_AutoRatio.ms"
	)

	macroScript SelectSmallObjects
	category:"-- PixGrinder --"
	toolTip:"Select small objects"
	buttonText:"Select small objects"
	-- icon:#("Splines",3)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Select_Small_Objects.ms"
	)

	macroScript CornerVertex
	category:"-- PixGrinder --"
	toolTip:"Corner"
	buttonText:"Corner"
	-- icon:#("Splines",3)
	silentErrors:true
	autoUndoEnabled:true
	(
		Include "$userScripts/PixGrinder/Corner_Vertex.ms"
	)

)


forgot script update

forgot script update

---------------------------------------------------------------------------------------------------------
-- Custom import/export dialog with settings

rollout AlembicImportSettings "Alembic Import Settings" width:288 height:244
(
    local filename

	GroupBox geoGroup "Geometry" pos:[8,8] width:272 height:212
	checkbox normalCheckbox "Normals" pos:[48,32] width:200 height:15 checked:true
	checkbox uvCheckbox "UVs" pos:[48,48] width:200 height:15 checked:true
    --checkbox clustersCheckbox "Clusters" pos:[48,64] width:200 height:15 checked:true
	checkbox attachCheckbox "Attach to existing objects" pos:[48,64] width:200 height:15 checked:false

	button importButton "Import" pos:[16,212] width:64 height:24
	button cancelButton "Cancel" pos:[208,212] width:64 height:24
	--GroupBox grpVisibility "Visibility" pos:[9,121] width:272 height:46
	--dropdownList dropDownVis "" pos:[20,140] width:252 height:21 items:#("Just Import Value", "Connected Controllers") selection:1
	checkbox materialIdsCheckbox "Material Ids" pos:[48,82] width:145 height:16 checked:true
    checkbox geoFromTopoCheckbox "Load Geometry From Topology Modifier" pos:[48,100] width:220 height:16 checked:false
    checkbox loadTimeControlCheckbox "Use Time Control" pos:[48,118] width:220 height:16 checked:true
    checkbox loadCurvesAsNurbsCheckbox "Load Curves as NURBS" pos:[48,136] width:220 height:16 checked:true
    checkbox meshSmoothModifiersCheckbox "Mesh Smooth Modifiers" pos:[48,152] width:220 height:16 checked:true
    dropdownList objectDuplication "Object Duplication" pos:[48,168] width:200 height:40 items:#("Copy", "Instance", "Reference") selection:1

	on importButton pressed do
	(
    	jobString = "filename=" + (filename as string)
    	jobString += ";normals="
    	jobString += (normalCheckbox.checked as string)
    	jobString += ";uvs="
    	jobString += (uvCheckbox.checked as string)
    	jobString += ";attachToExisting="
    	jobString += (attachCheckbox.checked as string)
        jobString += ";loadGeometryInTopologyModifier="
        jobString += (geoFromTopoCheckbox.checked as string)
        jobString += ";loadTimeControl="
        jobString += (loadTimeControlCheckbox.checked as string)
        jobString += ";loadCurvesAsNurbs="
        jobString += (loadCurvesAsNurbsCheckbox.checked as string)
        jobString += ";meshSmoothModifiers="
        jobString += (meshSmoothModifiersCheckbox.checked as string)

        if(objectDuplication.selection == 1) do
        (
            jobString += ";objectDuplication=copy"
        )
        if(objectDuplication.selection == 2) do
        (
            jobString += ";objectDuplication=instance"
        )
        if(objectDuplication.selection == 3) do
        (
            jobString += ";objectDuplication=reference"
        )

    	result = ExocortexAlembic.createImportJob(jobString)

	    --result = ExocortexAlembic.import filename normalCheckbox.checked uvCheckbox.checked materialIdsCheckbox.checked attachCheckbox.checked 0
	    if( result != 0 ) do
	    (
	    	messageBox "Failure - See Maxscript Listener for details." title:"Exocortex Alembic Import"
	    )
		destroyDialog AlembicImportSettings
	)
	on cancelButton pressed do
	(
	    destroyDialog AlembicImportSettings
	)
)
---------------------------------------------------------------------------------------------------------
-- MAXScript functions to bring up the options dialogs

fn alembicImportDialog =
(
    filename = getOpenFileName caption:"Import from Alembic File:" types:"Alembic(*.abc)|*.abc|All(*.*)|*.*" historyCategory:"Alembic"
    if (filename != undefined) do
    (
        createDialog AlembicImportSettings
        AlembicImportSettings.filename = filename
    )
)

---------------------------------------------------------------------------------------------------------
-- MacroScript to link the menu items to MAXScript functions

macroScript AlembicImportUI
    category:"Alembic"
    buttonText:"Alembic Import..."
    tooltip:"Alembic Import..."
(
    on execute do
    (
        alembicImportDialog()
    )
)

---------------------------------------------------------------------------------------------------------
-- Custom import/export dialog with settings

rollout AlembicImportSettings "Alembic Import Settings" width:288 height:204
(
    local filename

	GroupBox geoGroup "Geometry" pos:[8,8] width:272 height:172
	checkbox normalCheckbox "Normals" pos:[48,32] width:200 height:15 checked:true
	checkbox uvCheckbox "UVs" pos:[48,48] width:200 height:15 checked:true
    --checkbox clustersCheckbox "Clusters" pos:[48,64] width:200 height:15 checked:true
	checkbox attachCheckbox "Attach to existing objects" pos:[48,64] width:200 height:15 checked:false

	button importButton "Import" pos:[16,172] width:64 height:24
	button cancelButton "Cancel" pos:[208,172] width:64 height:24
	--GroupBox grpVisibility "Visibility" pos:[9,121] width:272 height:46
	--dropdownList dropDownVis "" pos:[20,140] width:252 height:21 items:#("Just Import Value", "Connected Controllers") selection:1
	checkbox materialIdsCheckbox "Material Ids" pos:[48,82] width:145 height:16 checked:true
    checkbox geoFromTopoCheckbox "Load Geometry From Topology Modifier" pos:[48,100] width:220 height:16 checked:false
    checkbox loadTimeControlCheckbox "Use Time Control" pos:[48,118] width:220 height:16 checked:true
    checkbox loadCurvesAsNurbsCheckbox "Load Curves as NURBS" pos:[48,136] width:220 height:16 checked:true
    checkbox meshSmoothModifiersCheckbox "Mesh Smooth Modifiers" pos:[48,152] width:220 height:16 checked:true

	on importButton pressed do
	(
    	jobString = "filename=" + (filename as string)
    	jobString += ";normals="
    	jobString += (normalCheckbox.checked as string)
    	jobString += ";uvs="
    	jobString += (uvCheckbox.checked as string)
    	jobString += ";attachToExisting="
    	jobString += (attachCheckbox.checked as string)
        jobString += ";loadGeometryInTopologyModifier="
        jobString += (geoFromTopoCheckbox.checked as string)
        jobString += ";loadTimeControl="
        jobString += (loadTimeControlCheckbox.checked as string)
        jobString += ";loadCurvesAsNurbs="
        jobString += (loadCurvesAsNurbsCheckbox.checked as string)
        jobString += ";meshSmoothModifiers="
        jobString += (meshSmoothModifiersCheckbox.checked as string)

    	result = ExocortexAlembic.createImportJob(jobString)

	    --result = ExocortexAlembic.import filename normalCheckbox.checked uvCheckbox.checked materialIdsCheckbox.checked attachCheckbox.checked 0
	    if( result != 0 ) do
	    (
	    	messageBox "Failure - See Maxscript Listener for details." title:"Exocortex Alembic Import"
	    )
		destroyDialog AlembicImportSettings
	)
	on cancelButton pressed do
	(
	    destroyDialog AlembicImportSettings
	)
)
---------------------------------------------------------------------------------------------------------
-- MAXScript functions to bring up the options dialogs

fn alembicImportDialog =
(
    filename = getOpenFileName caption:"Import from Alembic File:" types:"Alembic(*.abc)|*.abc|All(*.*)|*.*" historyCategory:"Alembic"
    if (filename != undefined) do
    (
        createDialog AlembicImportSettings
        AlembicImportSettings.filename = filename
    )
)

---------------------------------------------------------------------------------------------------------
-- MacroScript to link the menu items to MAXScript functions

macroScript AlembicImportUI
    category:"Alembic"
    buttonText:"Alembic Import..."
    tooltip:"Alembic Import..."
(
    on execute do
    (
        alembicImportDialog()
    )
)


connect camera transforms, disable connection for other cam params, because it doesn't work right (Issue #448)

fn findTimeControl = (
	if selection.count == 0 then print "Cannot find time control. Selection is empty."

	for i = 1 to selection.count do
	(
		if classof selection[i] == AlembicTimeControl then
		(
			return selection[i]
		)
	)
)

fn connectTimeControl obj timeCtrl = (
	--print obj
	if obj.time.isAnimated then
	(
		obj.time.controller = float_expression()
		local nCtrl = obj.time.controller
		nCtrl.AddScalarTarget "current" timeCtrl.time.controller
		nCtrl.setExpression "current"

		--print "connected"
	)
	else
	(
		--print "not animated"
	)
 )

fn createTimeControl name = (
	cntl = AlembicTimeControl name: name
)

fn connectTimeControlToObjects timeCtrl = (

	if selection.count == 0 then print "Cannot connect time control to objects. Selection is empty."

	for i = 1 to selection.count do
	(
		local n = selection[i]

		if classof n == Dummy then
		(
			if n.transform.isAnimated and \
				classof n.transform.controller == Alembic_Xform then
			(
				connectTimeControl n.transform.controller timeCtrl
			)
		)

		if classof n == PolyMeshObject or \
		classof n == Freecamera or \
		classof n == Alembic_Particles or \
		classof n == NURBSCurveshape or \
		classof n == SplineShape then
		(

			if n.transform.isAnimated and \
				classof n.transform.controller == Alembic_Xform then
			(
				connectTimeControl n.transform.controller timeCtrl
			)

			if n.visibility.isAnimated and \
				classof n.visibility.controller == Alembic_Visibility then
			(
				connectTimeControl n.visibility.controller timeCtrl
			)
		)

		if classof n == PolyMeshObject then
		(

			for j = 1 to n.modifiers.count do
			(
				modj = n.modifiers[j]
				case (classof modj) of
				(
					Alembic_Mesh_Normals:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_Geometry:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_UVW:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_Topology:
					(
						connectTimeControl modj timeCtrl
					)
				)
			)

		)
		else if classof n == Freecamera then
		(
			--connectTimeControl n.FOV timeCtrl
			--connectTimeControl n.MultiPass_Effect.focalDepth timeCtrl
			--connectTimeControl n.nearclip timeCtrl
			--connectTimeControl n.farclip timeCtrl

			--local camMod = n.modifiers["Alembic Camera Properties"]
			--if camMod != undefined then
			--(
			--	connectTimeControl camMod.hfov timeCtrl
			--	connectTimeControl camMod.vfov timeCtrl
			--	connectTimeControl camMod.focallength timeCtrl
			--	connectTimeControl camMod.haperature timeCtrl
			--	connectTimeControl camMod.vaperature timeCtrl
			--	connectTimeControl camMod.hfilmoffset timeCtrl
			--	connectTimeControl camMod.vfilmoffset timeCtrl
			--	connectTimeControl camMod.lsratio timeCtrl
			--	connectTimeControl camMod.loverscan timeCtrl
			--	connectTimeControl camMod.roverscan timeCtrl
			--	connectTimeControl camMod.toverscan timeCtrl
			--	connectTimeControl camMod.boverscan timeCtrl
			--	connectTimeControl camMod.fstop timeCtrl
			--	connectTimeControl camMod.focusdistance timeCtrl
			--	connectTimeControl camMod.shutteropen timeCtrl
			--	connectTimeControl camMod.shutterclose timeCtrl
			--	connectTimeControl camMod.nclippingplane timeCtrl
			--	connectTimeControl camMod.fclippingplane timeCtrl
			--)
		)
		else if classof n == Alembic_Particles then
		(
			connectTimeControl n timeCtrl
		)
		else if classof n == NURBSCurveshape then
		(
			for j = 1 to n.modifiers.count do
			(
				modj = n.modifiers[j]
				case (classof modj) of
				(
					Alembic_NURBS:
					(
						connectTimeControl modj timeCtrl
					)
				)
			)
		)
		else if classof n == SplineShape then
		(
			for j = 1 to n.modifiers.count do
			(
				modj = n.modifiers[j]
				case (classof modj) of
				(
					Alembic_Spline_Geometry:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Spline_Topology:
					(
						connectTimeControl modj timeCtrl
					)
				)
			)
		)
	)

)

macroScript NewTimeControlUI
    category:"Alembic"
    buttonText:"Create Time Control"
    tooltip:"Create Time Control"
(
    on execute do
    (
         AlembicTimeControl()
    )
)

macroScript NewTimeControlForSelectionUI
    category:"Alembic"
    buttonText:"New Time Control For Selection"
    tooltip:"New Time Control For Selection"
(
    on execute do
    (
    	local timeCtrl = AlembicTimeControl()
        connectTimeControlToObjects(timeCtrl)
    )
)

macroScript SetTimeControlForSelectionUI
    category:"Alembic"
    buttonText:"Set Time Control For Selection"
    tooltip:"Set Time Control For Selection"
(
    on execute do
    (
    	local timeCtrl = findTimeControl()
    	if timeCtrl != undefined then
    	(
    		connectTimeControlToObjects(timeCtrl)
    	)
    	else
    	(
    		print "Could not find time control in selection."
    	)
    )
)

fn findTimeControl = (
	if selection.count == 0 then print "Cannot find time control. Selection is empty."

	for i = 1 to selection.count do
	(
		if classof selection[i] == AlembicTimeControl then
		(
			return selection[i]
		)
	)
)

fn connectTimeControl obj timeCtrl = (
	--print obj
	if obj.time.isAnimated then
	(
		obj.time.controller = float_expression()
		local nCtrl = obj.time.controller
		nCtrl.AddScalarTarget "current" timeCtrl.time.controller
		nCtrl.setExpression "current"

		--print "connected"
	)
	else
	(
		--print "not animated"
	)
 )

fn createTimeControl name = (
	cntl = AlembicTimeControl name: name
)

fn connectTimeControlToObjects timeCtrl = (

	if selection.count == 0 then print "Cannot connect time control to objects. Selection is empty."

	for i = 1 to selection.count do
	(
		local n = selection[i]

		if classof n == Dummy then
		(
			if n.transform.isAnimated and \
				classof n.transform.controller == Alembic_Xform then
			(
				connectTimeControl n.transform.controller timeCtrl
			)
		)

		if classof n == PolyMeshObject or \
		classof n == Alembic_Particles or \
		classof n == NURBSCurveshape or \
		classof n == SplineShape then
		(

			if n.transform.isAnimated and \
				classof n.transform.controller == Alembic_Xform then
			(
				connectTimeControl n.transform.controller timeCtrl
			)

			if n.visibility.isAnimated and \
				classof n.visibility.controller == Alembic_Visibility then
			(
				connectTimeControl n.visibility.controller timeCtrl
			)
		)

		if classof n == PolyMeshObject then
		(

			for j = 1 to n.modifiers.count do
			(
				modj = n.modifiers[j]
				case (classof modj) of
				(
					Alembic_Mesh_Normals:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_Geometry:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_UVW:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_Topology:
					(
						connectTimeControl modj timeCtrl
					)
				)
			)

		)
		else if classof n == Freecamera then
		(
			connectTimeControl n.FOV timeCtrl
			connectTimeControl n.MultiPass_Effect.focalDepth timeCtrl
			connectTimeControl n.nearclip timeCtrl
			connectTimeControl n.farclip timeCtrl

			--local camMod = n.modifiers["Alembic Camera Properties"]
			--if camMod != undefined then
			--(
			--	connectTimeControl camMod.hfov timeCtrl
			--	connectTimeControl camMod.vfov timeCtrl
			--	connectTimeControl camMod.focallength timeCtrl
			--	connectTimeControl camMod.haperature timeCtrl
			--	connectTimeControl camMod.vaperature timeCtrl
			--	connectTimeControl camMod.hfilmoffset timeCtrl
			--	connectTimeControl camMod.vfilmoffset timeCtrl
			--	connectTimeControl camMod.lsratio timeCtrl
			--	connectTimeControl camMod.loverscan timeCtrl
			--	connectTimeControl camMod.roverscan timeCtrl
			--	connectTimeControl camMod.toverscan timeCtrl
			--	connectTimeControl camMod.boverscan timeCtrl
			--	connectTimeControl camMod.fstop timeCtrl
			--	connectTimeControl camMod.focusdistance timeCtrl
			--	connectTimeControl camMod.shutteropen timeCtrl
			--	connectTimeControl camMod.shutterclose timeCtrl
			--	connectTimeControl camMod.nclippingplane timeCtrl
			--	connectTimeControl camMod.fclippingplane timeCtrl
			--)
		)
		else if classof n == Alembic_Particles then
		(
			connectTimeControl n timeCtrl
		)
		else if classof n == NURBSCurveshape then
		(
			for j = 1 to n.modifiers.count do
			(
				modj = n.modifiers[j]
				case (classof modj) of
				(
					Alembic_NURBS:
					(
						connectTimeControl modj timeCtrl
					)
				)
			)
		)
		else if classof n == SplineShape then
		(
			for j = 1 to n.modifiers.count do
			(
				modj = n.modifiers[j]
				case (classof modj) of
				(
					Alembic_Spline_Geometry:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Spline_Topology:
					(
						connectTimeControl modj timeCtrl
					)
				)
			)
		)
	)

)

macroScript NewTimeControlUI
    category:"Alembic"
    buttonText:"Create Time Control"
    tooltip:"Create Time Control"
(
    on execute do
    (
         AlembicTimeControl()
    )
)

macroScript NewTimeControlForSelectionUI
    category:"Alembic"
    buttonText:"New Time Control For Selection"
    tooltip:"New Time Control For Selection"
(
    on execute do
    (
    	local timeCtrl = AlembicTimeControl()
        connectTimeControlToObjects(timeCtrl)
    )
)

macroScript SetTimeControlForSelectionUI
    category:"Alembic"
    buttonText:"Set Time Control For Selection"
    tooltip:"Set Time Control For Selection"
(
    on execute do
    (
    	local timeCtrl = findTimeControl()
    	if timeCtrl != undefined then
    	(
    		connectTimeControlToObjects(timeCtrl)
    	)
    	else
    	(
    		print "Could not find time control in selection."
    	)
    )
)


Support NURBS and Splines, support transforms and visibility for particles (Issue #429)

fn findTimeControl = (
	if selection.count == 0 then print "Cannot find time control. Selection is empty."

	for i = 1 to selection.count do
	(
		if classof selection[i] == AlembicTimeControl then
		(
			return selection[i]
		)
	)
)

fn connectTimeControl obj timeCtrl = (
	print obj
	if obj.time.isAnimated then
	(
		obj.time.controller = float_expression()
		local nCtrl = obj.time.controller
		nCtrl.AddScalarTarget "current" timeCtrl.time.controller
		nCtrl.setExpression "current"

		print "connected"
	)
	else
	(
		print "not animated"
	)
 )

fn createTimeControl name = (
	cntl = AlembicTimeControl name: name
)

fn connectTimeControlToObjects timeCtrl = (

	if selection.count == 0 then print "Cannot connect time control to objects. Selection is empty."

	if timeCtrl == undefined then
	(
		timeCtrl = AlembicTimeControl()
	)

	for i = 1 to selection.count do
	(
		local n = selection[i]

		if classof n == PolyMeshObject or \
		classof n == Alembic_Particles or \
		classof n == NURBSCurveshape or \
		classof n == SplineShape then
		(

			if n.transform.isAnimated and \
				classof n.transform.controller == Alembic_Xform then
			(
				connectTimeControl n.transform.controller timeCtrl
			)

			if n.visibility.isAnimated and \
				classof n.visibility.controller == Alembic_Visibility then
			(
				connectTimeControl n.visibility.controller timeCtrl
			)
		)

		if classof n == PolyMeshObject then
		(

			for j = 1 to n.modifiers.count do
			(
				modj = n.modifiers[j]
				case (classof modj) of
				(
					Alembic_Mesh_Normals:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_Geometry:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_UVW:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_Topology:
					(
						connectTimeControl modj timeCtrl
					)
				)
			)

		)
		else if classof n == Freecamera then
		(
			connectTimeControl n.FOV timeCtrl
			connectTimeControl n.MultiPass_Effect.focalDepth timeCtrl
			connectTimeControl n.nearclip timeCtrl
			connectTimeControl n.farclip timeCtrl

			--local camMod = n.modifiers["Alembic Camera Properties"]
			--if camMod != undefined then
			--(
			--	connectTimeControl camMod.hfov timeCtrl
			--	connectTimeControl camMod.vfov timeCtrl
			--	connectTimeControl camMod.focallength timeCtrl
			--	connectTimeControl camMod.haperature timeCtrl
			--	connectTimeControl camMod.vaperature timeCtrl
			--	connectTimeControl camMod.hfilmoffset timeCtrl
			--	connectTimeControl camMod.vfilmoffset timeCtrl
			--	connectTimeControl camMod.lsratio timeCtrl
			--	connectTimeControl camMod.loverscan timeCtrl
			--	connectTimeControl camMod.roverscan timeCtrl
			--	connectTimeControl camMod.toverscan timeCtrl
			--	connectTimeControl camMod.boverscan timeCtrl
			--	connectTimeControl camMod.fstop timeCtrl
			--	connectTimeControl camMod.focusdistance timeCtrl
			--	connectTimeControl camMod.shutteropen timeCtrl
			--	connectTimeControl camMod.shutterclose timeCtrl
			--	connectTimeControl camMod.nclippingplane timeCtrl
			--	connectTimeControl camMod.fclippingplane timeCtrl
			--)
		)
		else if classof n == Alembic_Particles then
		(
			connectTimeControl n timeCtrl
		)
		else if classof n == NURBSCurveshape then
		(
			for j = 1 to n.modifiers.count do
			(
				modj = n.modifiers[j]
				case (classof modj) of
				(
					Alembic_NURBS:
					(
						connectTimeControl modj timeCtrl
					)
				)
			)
		)
		else if classof n == SplineShape then
		(
			for j = 1 to n.modifiers.count do
			(
				modj = n.modifiers[j]
				case (classof modj) of
				(
					Alembic_Spline_Geometry:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Spline_Topology:
					(
						connectTimeControl modj timeCtrl
					)
				)
			)
		)
	)

)

macroScript NewTimeControlUI
    category:"Alembic"
    buttonText:"Create Time Control"
    tooltip:"Create Time Control"
(
    on execute do
    (
         AlembicTimeControl()
    )
)

macroScript NewTimeControlForSelectionUI
    category:"Alembic"
    buttonText:"New Time Control For Selection"
    tooltip:"New Time Control For Selection"
(
    on execute do
    (
    	local timeCtrl = AlembicTimeControl()
        connectTimeControlToObjects(timeCtrl)
    )
)

macroScript SetTimeControlForSelectionUI
    category:"Alembic"
    buttonText:"Set Time Control For Selection"
    tooltip:"Set Time Control For Selection"
(
    on execute do
    (
    	local timeCtrl = findTimeControl()
    	if timeCtrl != undefined then
    	(
    		connectTimeControlToObjects(timeCtrl)
    	)
    	else
    	(
    		print "Could not find time control in selection."
    	)
    )
)

fn findTimeControl = (
	if selection.count == 0 then print "Cannot find time control. Selection is empty."

	for i = 1 to selection.count do
	(
		if classof selection[i] == AlembicTimeControl then
		(
			return selection[i]
		)
	)
)

fn connectTimeControl obj timeCtrl = (
	print obj
	if obj.time.isAnimated then
	(
		obj.time.controller = float_expression()
		local nCtrl = obj.time.controller
		nCtrl.AddScalarTarget "current" timeCtrl.time.controller
		nCtrl.setExpression "current"

		print "connected"
	)
	else
	(
		print "not animated"
	)
 )

fn createTimeControl name = (
	cntl = AlembicTimeControl name: name
)

fn connectTimeControlToObjects timeCtrl = (

	if selection.count == 0 then print "Cannot connect time control to objects. Selection is empty."

	if timeCtrl == undefined then
	(
		timeCtrl = AlembicTimeControl()
	)

	for i = 1 to selection.count do
	(
		local n = selection[i]

		if classof n == PolyMeshObject then
		(

			if n.transform.isAnimated and \
				classof n.transform.controller == Alembic_Xform then
			(
				connectTimeControl n.transform.controller timeCtrl
			)

			if n.visibility.isAnimated and \
				classof n.visibility.controller == Alembic_Visibility then
			(
				connectTimeControl n.visibility.controller timeCtrl
			)

			for j = 1 to n.modifiers.count do
			(
				modj = n.modifiers[j]
				case (classof modj) of
				(
					Alembic_Mesh_Normals:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_Geometry:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_UVW:
					(
						connectTimeControl modj timeCtrl
					)
					Alembic_Mesh_Topology:
					(
						connectTimeControl modj timeCtrl
					)
				)
			)

		)
		else if classof n == Freecamera then
		(
			connectTimeControl n.FOV timeCtrl
			connectTimeControl n.MultiPass_Effect.focalDepth timeCtrl
			connectTimeControl n.nearclip timeCtrl
			connectTimeControl n.farclip timeCtrl

			--local camMod = n.modifiers["Alembic Camera Properties"]
			--if camMod != undefined then
			--(
			--	connectTimeControl camMod.hfov timeCtrl
			--	connectTimeControl camMod.vfov timeCtrl
			--	connectTimeControl camMod.focallength timeCtrl
			--	connectTimeControl camMod.haperature timeCtrl
			--	connectTimeControl camMod.vaperature timeCtrl
			--	connectTimeControl camMod.hfilmoffset timeCtrl
			--	connectTimeControl camMod.vfilmoffset timeCtrl
			--	connectTimeControl camMod.lsratio timeCtrl
			--	connectTimeControl camMod.loverscan timeCtrl
			--	connectTimeControl camMod.roverscan timeCtrl
			--	connectTimeControl camMod.toverscan timeCtrl
			--	connectTimeControl camMod.boverscan timeCtrl
			--	connectTimeControl camMod.fstop timeCtrl
			--	connectTimeControl camMod.focusdistance timeCtrl
			--	connectTimeControl camMod.shutteropen timeCtrl
			--	connectTimeControl camMod.shutterclose timeCtrl
			--	connectTimeControl camMod.nclippingplane timeCtrl
			--	connectTimeControl camMod.fclippingplane timeCtrl
			--)
		)
		else if classof n == Alembic_Particles then
		(
			connectTimeControl n timeCtrl
		)
		-- nurbs
		-- splines
		-- new menu options
		-- documentation
	)

)

macroScript NewTimeControlUI
    category:"Alembic"
    buttonText:"Create Time Control"
    tooltip:"Create Time Control"
(
    on execute do
    (
         AlembicTimeControl()
    )
)

macroScript NewTimeControlForSelectionUI
    category:"Alembic"
    buttonText:"New Time Control For Selection"
    tooltip:"New Time Control For Selection"
(
    on execute do
    (
    	local timeCtrl = AlembicTimeControl()
        connectTimeControlToObjects(timeCtrl)
    )
)

macroScript SetTimeControlForSelectionUI
    category:"Alembic"
    buttonText:"Set Time Control For Selection"
    tooltip:"Set Time Control For Selection"
(
    on execute do
    (
    	local timeCtrl = findTimeControl()
    	if timeCtrl != undefined then
    	(
    		connectTimeControlToObjects(timeCtrl)
    	)
    	else
    	(
    		print "Could not find time control in selection."
    	)
    )
)