I’m having a problem in 3ds max 2020 where I want to use the Projection modifier to project vertex colors from a high-density mesh onto a low-density one. Doing this by hand works fine. I have the beginnings of a script to automate it:
AddPModObjects #(projectorObj) true true objList:#(orig) proj = projectorObj.modifiers[#Projection] projMap = proj.getProjectionType 1 projMap.createNewHolder = true projMap.sameAsSource = true --Would like to set source channel here proj.projectAll()
The problem is that I don’t see how the source channel option is exposed to MaxScript. if I look at the docs or run showProperties on projMap, I see:
.name : string .holderName (Projection_Holder_Name) : string .alwaysUpdate (Always_Update_Holder) : boolean .createNewHolder (Create_New_Holder) : boolean .sourceMapChannel (Source_Map_Channel) : integer .sameAsSource (Same_as_Source) : boolean .targetMapChannel (Target_Map_Channel) : integer .projectMaterialIDs (Project_Material_IDs) : boolean .sameTopology (Same_Topology) : boolean .ignoreBackfacing (Ignore_Backfacing) : boolean .testSeams (Test_Seams) : boolean .checkEdgeRatios (Check_Edge_Ratios) : boolean .weldUVs (Weld_UVs) : boolean .weldUVsThreshold (Weld_UVs_Threshold) : float .edgeRatioThreshold (Edge_Ratio_Threshold) : float
The most similar one is `sourceMapChannel`, but changing that only changes the integer map channel for the “Map Channel” source type - the red X in my screenshot. How can I set the radio button for the green arrow, “Vertex Color” from maxscript?
Solved! Go to Solution.
You can always send a click to the control you want to trigger:
(
local projectorObj = ...
local orig = ...
local iGlobal = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
fn sendClick hWnd =
(
local WM_LBUTTONDOWN = 0x0201
windows.postMessage hwnd WM_LBUTTONDOWN 0 0
windows.postMessage hwnd (WM_LBUTTONDOWN + 1) 0 0
)
SetCommandPanelTaskMode #modify
AddPModObjects #(projectorObj) true true objList:#(orig)
local proj = projectorObj.modifiers[#Projection]
proj.addRegisteredProjectionType 1
projMap = proj.getProjectionType 1
projMap.createNewHolder = true
projMap.sameAsSource = true
local cmdPanelWindows = windows.getChildrenHWnd ((iGlobal.UtilGetCoreInterface16()).CommandPanelRollup.Hwnd)
local vertexColorBtn = for item in cmdPanelWindows where
toLower (getFilenameFile (UIAccessor.getWindowDllFileName item[1])) == "projectionmodtypeuvw" and
UIAccessor.getWindowResourceID item[1] == 1073 do exit with item[1]
if isKindOf vertexColorBtn Number do sendClick vertexColorBtn
)
Yes, the modifier UI has to be ready to receive input.
I've asked this same question on the CG talk forums and got another answer:
projMap.sourceMapChannel = 0
Interestingly you can also use negative numbers to set the other radio buttons. Thanks for your involved answer all the same, @Swordslayer
Can't find what you're looking for? Ask the community or share your knowledge.