ScriptSpot

Script

mapDroper

By barigazy · Credited author: Branko Živković · 2012-08-21

Version
2.1
Version requirement
2010+
Date updated
2012-08-21
Votes
4
Downloads

Tags: map material editor bitmap

Description

----------------------------------------------------------------------------------------------------------- [version 2]

This little tool allows you to put a texture with drag and drop method from any folder to
specified slot of the Material Editor.

Additional Info

Just drag & drop map file to script label box (Drop Here).
If file is valid script will throw "OK" else "NO".
Not supports multiple draged files.
Supported materials are: Standard, VRayMtl, Arch & Design
Supported map types are: *.hdr, *.exr, *.jpg, *.tga, *.tif, *.bmp, *.png, *.jpeg, *.psd.
See the image below to see how it works:

This script is requested by roamn

Comments (8)

Another usage of this beautiful script-- Easy drag and drop impo

Jaber_Zaker_Joybari · 2017-06-30

Hi Branko

Thanks for sharing this beautiful script . I just reuse your script to easy drag and drop Image importer. Here it is

/*//////////   SCRIPT:   mapDroper v.1.0   //////////*/
/*//////////   WRITTEN BY:   Branko Zivkovic   //////////*/
/*//////////   EMAIL:   barigazy@hotmail.com   //////////*/
(
	try(destroydialog ::mapDrop) catch()
	rollout mapDrop "Easy Image Importer"
	(
		local mapExt = #(".hdr", ".exr", ".jpg", ".tga", ".tif", ".bmp", ".png", ".jpeg", ".psd"), dropState = off		
		local stdProps = #("diffuseMap")
		local classArr = #(Standardmaterial)
		dotnetcontrol drop "Label" pos:[5,5] width:150 height:40
		dotnetcontrol props "CheckedListBox" pos:[5,50] width:140 height:10
		radioButtons 'window_' "Window" pos:[10,60] width:78 height:30 labels:#("Top","Front") columns:2 align:#left
		
		mapped fn trimArr arr &new = (append new (substring arr 8 100))			
			
		fn checkIsImage arg arr =
		(
			arg.Data.ContainsFileDropList() and (arg.Data.GetFileDropList()).count == 1 and \
			(for ext in arr where matchpattern ext pattern:(getFilenameType (arg.Data.GetFileDropList()).item[0]) collect ext).count != 0
		)
		fn updateMat propctrl mtl map idx =
		(
			for ci in 0 to propctrl.CheckedItems.count-1 do
			(
				slotName = if idx == 2 then ("texmap_"+propctrl.CheckedItems.item[ci]) else propctrl.CheckedItems.item[ci]
				setProperty mtl slotName map
			)
		)

		
		on mapDrop open do
		(
			props.BackColor = drop.BackColor = (dotNetClass "System.Drawing.Color").FromArgb 40 40 40
			props.ForeColor = drop.ForeColor = (dotNetClass "System.Drawing.Color").FromArgb 200 200 200
			props.BorderStyle = drop.BorderStyle = (dotNetClass "BorderStyle").FixedSingle
			drop.Font = (dotNetObject "System.Drawing.Font" "Impact" 20)
			drop.TextAlign = drop.TextAlign.MiddleCenter
			props.HorizontalScrollbar = props.MultiColumn = false
			drop.Text = "Drop Image " ; drop.AllowDrop = props.CheckOnClick = true
			props.Items.AddRange stdProps
			--format "itm = %\n" mtltype.selection 
		)

		on drop DragOver s arg do
		( 
			arg.Effect = if checkIsImage arg mapExt then
			( 
				s.Text = "Done" ; dropState = on ; arg.Effect.Move
			) 
			else 
			(
				s.Text = "NO" ; dropState = off ; arg.Effect.None
			)
		)
		
		on drop DragDrop arg do
		(
		imgFile = (arg.Data.GetFileDropList()).item[0]
		tempMap = openBitMap imgFile
		imgPlane = plane name:(uniqueName("hhh" + (getfilenameFile imgFile))) length:(tempMap.height) width:(tempMap.width) lengthsegs:1 widthsegs:1 mapCoords:true isselected:true
			
------Import an image	START		
		case window_.state of
		(
			------Top
			1:(	imgPlane.transform = matrix3 1)
			-----Front 
			2:(imgPlane.transform = RotateXMatrix 90 )
		)	
		
		imgMaterial = standard()
		imgMaterial.name = imgPlane.name
		imgTexture = bitmaptexture()
		imgTexture.bitmap = tempMap
		imgMaterial.diffuseMap = imgTexture
		imgPlane.material = imgMaterial
		imgMaterial.twoSided = on
		showTextureMap imgMaterial imgMaterial.diffuseMap on
		close tempMap			
		)
	)
	
	
	createdialog mapDrop 160 100 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
)

If you are not OK with this just tell me to delete this post.

Thank again for sharing all your beautiful script

vidivini500 · 2017-02-15

Hi Barigazy, very nice script!
Is possible to add the option of drop more than one map at the same time?
Would be great.
Thanks for your work

VRAY Error

brainsgonedead · 2017-02-14

I use 3D Max 2017, but not VRAY so this shows a VRAY MTL error when I go to install. Hopefully this can be fixed...

...update 2.1

barigazy · 2017-02-14

Bug is fixed

kimarotta · 2012-08-22

Good Work... nice.

barigazy · 2012-08-22

Thanks Kim. Glad you like it

n0name · 2012-08-22

how to use this script?

barigazy · 2012-08-22

I update the script.See image, it very simple to use