Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Projection modifier: setting source type to “vertex color” from script

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
1204 Views, 5 Replies

Projection modifier: setting source type to “vertex color” from script

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:temp.png

  .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?

 

Labels (2)
5 REPLIES 5
Message 2 of 6
Swordslayer
in reply to: Anonymous

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
)

 

 

 

Message 3 of 6
Anonymous
in reply to: Anonymous

Edit - posted in wrong place

Message 4 of 6
Anonymous
in reply to: Swordslayer

Haha! Delightfully hacky. I suppose this would require having the GUI open? Currently this is part of a larger script which runs in headless mode, but if the alternative is having to sit there and do this part manually this is definitely an improvement. Will give this a try later today.
Message 5 of 6
Swordslayer
in reply to: Anonymous
Message 6 of 6
Anonymous
in reply to: Swordslayer

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.

Post to forums  

Autodesk Design & Make Report