Announcement

Collapse
No announcement yet.

Urgent maxscript help needed

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

  • Urgent maxscript help needed

    Hi all

    So I have a LOT of objects in the scene. I will select a bunch of them (couple of 10's of thousands) and then I need a maxscript command to assign a "Map Scaler OSM" to each of the objects seperately, and set the scale of the mapscaler to 1000mm

    Please help
    Kind Regards,
    Morne

  • #2
    This should create a unique modifer to each selected object.

    for i in selection do
    (
    MyModifier = MapScalerOSM ()
    MyModifier.scale = 1000
    addModifier i MyModifier
    )

    Comment


    • #3
      thanks
      if a particular object already has a mapscaler, how can I exclude that object from getting another one?
      Kind Regards,
      Morne

      Comment


      • #4
        Is the previous mapscaler modifier always on the top of the stack or just somewhere in there?

        Comment


        • #5
          somewhere in there
          Kind Regards,
          Morne

          Comment


          • #6
            That's a bit trickier... I'll try to do it later if no one else responds.

            Comment


            • #7
              thanks, if all else fails I'll just use yours as is. As far as I understand it will use the topmost one last, so that's fine, except in the odd occasion where I have the previous one set to channel2
              Kind Regards,
              Morne

              Comment


              • #8
                Building on Berglte's script:

                This will check for a previous MapScalerOSM mod and make sure it doesn't get applied twice:

                Code:
                (
                	local modFound
                	
                	objs = getCurrentSelection()
                	
                	for o in objs do (
                		-- Reset the modFound variable each object
                		modFound = false
                		
                		-- Check all modifiers for a MapScalerOSM
                		for i = 1 to o.modifiers.count where (classof o.modifiers[i]) == MapScalerOSM do
                			modFound = true
                		
                		-- The mod isn't on this particular object
                		if not(modFound) then (
                			if validModifier o MapScalerOSM then (
                				myModifier = MapScalerOSM()
                				myModifier.scale = 1000
                				addModifier o myModifier
                			)
                		)
                	)
                )
                Do you need the code to set all mapScalerOSM's to 1000 or you good?
                Colin Senner

                Comment


                • #9
                  Nice!

                  I also managed to get it working after searching for a while. Bobos examples helped once again

                  for i in selection where
                  (for m in i.modifiers where classOf m == MapScalerOSM collect m).count == 0 do
                  (
                  MyModifier = (MapScalerOSM())
                  MyModifier.Scale = 1000
                  addModifier i MyModifier
                  )

                  Comment


                  • #10
                    You'll want a check in the berglte to make sure the modifier is valid before you add it (validModifier) otherwise the script will fail on camera/light selections. . I expanded mine for clarity too so it can be retrofitted by someone else with a similar issue. Cheers.
                    Colin Senner

                    Comment


                    • #11
                      Alright, thanks for pointing that out!

                      Comment

                      Working...