Announcement

Collapse
No announcement yet.

Material match by pick?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Material match by pick?

    Hello members!

    I have a question, but not sure on the proper terminology...

    For those of you with AutoCAD experience, I am basically looking for something, in max, that emulates AutoCAD's "MATCHPROP" command.

    Reason is that as I develop a scene, a lot of times, I want to finish modeling something, and be able to-

    1] click button "A"
    2] pick(select) an existing geometry/model that already has a material (example: "Wood Planks V-ray") assigned to it.
    3] pick (select) second piece of geometry (and viola, "Wood Planks V-ray" is now assigned to second piece of geometry.)

    So, in 3 clicks I could create a new wood plank geometry, and apply the proper material to it, all without opening, dealing with, and closing the material editor...

    I hope it is clear enough what I'm after as an end result...

    Thanks in advance for any useful tips with this post...

  • #2
    Nope - nearest thing is to open the material editor, pick a slot to temporarily use for your material, use the eye dropper beside the mat name to pick a material from your object, then select the second object and assign it to selection.

    Comment


    • #3
      Too damned bad - but thanks anyway, jconnell.

      Comment


      • #4
        Is it specifically this and nothing else that you want to do?

        Comment


        • #5
          Paste this code into a new script in the maxscript editor, then drag it to a toolbar to make a button. Seems to do what you want. Might be worth doing a hold first in case something blows up!

          Code:
          TheObjArray = selection as array
          
          fn GeoFilt o = (superClassOf o == GeometryClass)
          -- which you could use like this:
          theMaterialObj = pickObject prompt:"Pick an object to take a material from" filter:GeoFilt
          
          for i = 1 to TheObjArray.count do
          (
          	TheObjArray[i].material = theMaterialObj.material
          )

          Comment


          • #6
            Yeah, that's really all I was looking to do...Thanks for that script, I'm going to try it right now!

            Comment


            • #7
              Mathprop for Max v1

              jconnell, thanks a lot, it works perfectly and is so very efficient!

              Comment


              • #8
                Good deed for the day done!

                Comment


                • #9
                  really appreciate it...

                  Comment


                  • #10
                    Works perfectly, but is there a way to stop it from doing one odd thing?

                    let's say I am in "rotate" or "select object" mode and run the script. Script works as expected, but afterward, it leaves me in "move" mode instead of whatever mode I was in before running script.
                    Is that easy to fix?

                    Thanks again, I use this all the time!

                    Comment


                    • #11
                      Code:
                      theToolMode = toolmode.commandmode
                      
                      TheObjArray = selection as array
                      
                      fn GeoFilt o = (superClassOf o == GeometryClass)
                      -- which you could use like this:
                      theMaterialObj = pickObject prompt:"Pick an object to take a material from" filter:GeoFilt
                      
                      for i = 1 to TheObjArray.count do
                      (
                      	TheObjArray[i].material = theMaterialObj.material
                      )
                      
                      toolmode.commandmode = theToolMode

                      Comment


                      • #12
                        I've wanted to knock something like this up for ages, this is pretty bad code but hopefully of some help to you/others.

                        Code:
                        global CopyMat
                        global CurrentTool
                        fn GeoFilt o = (superClassOf o == GeometryClass)
                        CurrentTool = toolmode.commandmode 
                        --ROLLOUT
                        	
                        rollout MatPickRO "Pick Source"
                        	(			
                        		pickbutton PickSource "Pick Source" width:80 filter:GeoFilt 
                        		on PickSource picked SourceObj do  	
                        		(
                        			if SourceObj != undefined do
                        			(
                        				if SourceObj.material != undefined then
                        				(
                        					CopyMat = SourceObj.material
                        				)
                        				else (messagebox "Object has no material :(")
                        			)			
                        		)
                        		
                        		pickbutton PickTarget "Single Target" width:80 filter:GeoFilt count:#multiple forceListenerFocus:false
                        		on PickTarget picked targetObj do  	
                        		(
                        			--if targetObj != undefined do
                        			(
                        				if CopyMat != undefined then
                        				(
                        					for i in targetObj do 
                        						(
                        						i.material = CopyMat
                        						)					
                        				)else  (messagebox "No source picked :(")
                        			)
                        		)	
                        		
                        		checkbutton PickMultiple "Multi Targets" width:80
                        		on PickMultiple changed state do
                        	(
                        		if PickMultiple.state == on then 
                        		(
                        			if CopyMat != undefined then
                        				(
                        					PickMultArray = #()
                        					PickMultArray = pickobject count:#multiple forceListenerFocus:false filter:GeoFilt
                        					for i in PickMultArray do 
                        					(
                        						i.material = CopyMat
                        					)
                        				)
                        		)
                          		PickMultiple.state = off
                        		
                          	)		
                        	
                        		button CloseMatPick "Close"
                        		on CloseMatPick pressed do
                        		(
                        			DestroyDialog MatPickRO
                        			toolmode.commandmode = CurrentTool
                        		)
                        	)--End Rollout
                        createDialog MatPickRO 105 115
                        MDI Digital
                        moonjam

                        Comment


                        • #13
                          Originally posted by joconnell View Post
                          Code:
                          theToolMode = toolmode.commandmode
                          
                          TheObjArray = selection as array
                          
                          fn GeoFilt o = (superClassOf o == GeometryClass)
                          -- which you could use like this:
                          theMaterialObj = pickObject prompt:"Pick an object to take a material from" filter:GeoFilt
                          
                          for i = 1 to TheObjArray.count do
                          (
                              TheObjArray[i].material = theMaterialObj.material
                          )
                          
                          toolmode.commandmode = theToolMode
                          Works perfectly, thanks again!Click image for larger version

Name:	joconnells match script for voltron v2.jpg
Views:	1
Size:	25.9 KB
ID:	846481

                          Comment


                          • #14
                            Originally posted by AJ Jefferies View Post
                            I've wanted to knock something like this up for ages, this is pretty bad code but hopefully of some help to you/others.

                            Code:
                            global CopyMat
                            global CurrentTool
                            fn GeoFilt o = (superClassOf o == GeometryClass)
                            CurrentTool = toolmode.commandmode 
                            --ROLLOUT
                                
                            rollout MatPickRO "Pick Source"
                                (            
                                    pickbutton PickSource "Pick Source" width:80 filter:GeoFilt 
                                    on PickSource picked SourceObj do      
                                    (
                                        if SourceObj != undefined do
                                        (
                                            if SourceObj.material != undefined then
                                            (
                                                CopyMat = SourceObj.material
                                            )
                                            else (messagebox "Object has no material :(")
                                        )            
                                    )
                                    
                                    pickbutton PickTarget "Single Target" width:80 filter:GeoFilt count:#multiple forceListenerFocus:false
                                    on PickTarget picked targetObj do      
                                    (
                                        --if targetObj != undefined do
                                        (
                                            if CopyMat != undefined then
                                            (
                                                for i in targetObj do 
                                                    (
                                                    i.material = CopyMat
                                                    )                    
                                            )else  (messagebox "No source picked :(")
                                        )
                                    )    
                                    
                                    checkbutton PickMultiple "Multi Targets" width:80
                                    on PickMultiple changed state do
                                (
                                    if PickMultiple.state == on then 
                                    (
                                        if CopyMat != undefined then
                                            (
                                                PickMultArray = #()
                                                PickMultArray = pickobject count:#multiple forceListenerFocus:false filter:GeoFilt
                                                for i in PickMultArray do 
                                                (
                                                    i.material = CopyMat
                                                )
                                            )
                                    )
                                      PickMultiple.state = off
                                    
                                  )        
                                
                                    button CloseMatPick "Close"
                                    on CloseMatPick pressed do
                                    (
                                        DestroyDialog MatPickRO
                                        toolmode.commandmode = CurrentTool
                                    )
                                )--End Rollout
                            createDialog MatPickRO 105 115
                            Thanks for sharing, I am going to try it now...

                            Comment

                            Working...
                            X