unique maps collector function

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  01 January 2013
Originally Posted by denisT: how does it work for a scripted material?

I don't know. Why? But honestly I did not even think about it
Theses files that I mentioned earlier (archived) are mostly architestural buildings and furniture.
I do not believe that any of the designers use scripted material or maps because VRay, MentalRay,FinalRender,Maxwell etc. does not support many of them. . By the way thanks for reply.
How can I improve my last code and how to not affect instances maps. Any last advice?
__________________
Looking in the right side. [bgaTools]

Last edited by gazybara : 01 January 2013 at 11:01 PM.
 
  01 January 2013
Originally Posted by gazybara: I don't know. Why? But honestly I did not even think about it

scripted material extends one of the existing classes. and it may or may not propagate delegate class properties. so in general case you have to check when material is scripted, and search its delegate's properties as well.
 
  01 January 2013
Originally Posted by gazybara: How can I improve my last code?

what do you know about mapPaths?
 
  01 January 2013
Originally Posted by denisT: what do you know about mapPaths?

Just what I found in mxs help. A safe place to save and read maps
__________________
Looking in the right side. [bgaTools]

Last edited by gazybara : 01 January 2013 at 12:15 AM.
 
  01 January 2013
Originally Posted by gazybara: Just what I found in mxs help.

play with it... the understanding of it will help your to avoid mistakes that most of 'map remap' scripts do.
 
  01 January 2013
I create structDef but I'm not sure whether this is a good concept.
Maybe I need to check also "isDirectoryWriteable targetMapsFolderPath" because on win8 some directories are locked. I tried to figure out how this works Directory.GetAccessControl Method and it's right solution for unlocking?

    struct copyRepathFiles
    (
    	sourceFolderPath, targetMapsFolderPath,
    	mapped fn storeMP dirArr = (mapPaths.add dirArr),
    	msg str = (messageBox str title:"Warning" beep:off),
    	fn sourceFolderToMapPaths subDir:off =
    	(
    		local sioDir = dotNetClass "System.IO.Directory", result = false
    		if sioDir.Exists (this.sourceFolderPath) do
    		(
    			if mapPaths.count() != 0 do for p = mapPaths.count() to 1 by -1 do mapPaths.delete p
    			if not subDir then (mapPaths.add (this.sourceFolderPath) ; result = true) else
    			(
    				if (dirs = sioDir.GetDirectories (this.sourceFolderPath)).count != 0 do (this.storeMP dirs ; result = true)
    			)
    		) ; result
    	),	
    	fn getMtlMaps mtl maps = 
    	(
    		if mtl != undefined and mtl.numsubs != 0 do 
    		(
    			for m = 1 to mtl.numsubs where (mtl[m] != undefined) do 
    			(
    				if (isKindOf mtl[m] SubAnim) and (isKindOf mtl[m].Object textureMap) do 
    				(
    					for p in (getPropNames mtl[m].Object) where isKindOf (getProperty mtl[m].Object p) String do 
    					(
    						append maps #(mtl[m].Object , p, (filenameFromPath (getProperty mtl[m].Object p)))
    					)
    					getMtlMaps mtl[m] maps
    				)
    			)
    		)
    	),
    	fn copyAndRepath doCopy:on doRepath:on = if selection.count != 0 then msg "Select Some Objects" else
    	(
    		objs = for o in selection where o.material != undefined collect o
    		if objs.count == 0 then msg "Selected Objects Don't Have Assigned Material!" else
    		(
    			local result = sourceFolderToMapPaths subDir:on
    			if not result then msg "Incorect Source Folder Path!" else
    			(
    				local sioDir = dotNetClass "System.IO.Directory"
    				if not sioDir.Exists (this.targetMapsFolderPath) then msg "Incorect Target Folder Path!" else
    				(
    					local mapsArr = #()
    					for o in objs do getMtlMaps o.material mapsArr
    					if mapsArr.count == 0 then messageBox "Materials Don't Have Bitmaps!" else
    					(
    						local pcAP = pathConfig.appendPath
    						for m = 1 to mapsArr.count do
    						(
    							if (sourceMap = mapPaths.getFullFilePath mapsArr[m][3]) != "" do
    							(
    								targetMap = (pcAP (this.targetMapsFolderPath) mapsArr[m][3])
    								if doCopy do copyFile sourceMap targetMap
    								if doRepath do setproperty mapsArr[m][1] mapsArr[m][2] targetMap
    							)
    						) ; free mapsArr
    					)
    				)
    			)
    		)
    	)
    )
    
__________________
Looking in the right side. [bgaTools]

Last edited by gazybara : 01 January 2013 at 09:15 PM.
 
  01 January 2013
Originally Posted by gazybara: I create structDef but I'm not sure whether this is a good concept.
Maybe I need to check also "isDirectoryWriteable targetMapsFolderPath" because on win8 some directories are locked. I tried to figure out how this works Directory.GetAccessControl Method and it's right solution for unlocking?

that's what some guy suggests http://social.msdn.microsoft.com/Fo...4-bc534bbb03b4/
looks reasonable.
here is a translation do the maxscript:

directoryName =  @"c:\temp" -- for example
permissionSet = dotnetobject "System.Security.PermissionSet" (dotnetclass "System.Security.Permissions.PermissionState").None
writePermission = dotnetobject "System.Security.Permissions.FileIOPermission" (dotnetclass "System.Security.Permissions.FileIOPermissionAccess  ").Write directoryName
permissionSet.AddPermission writePermission
permissionSet.IsSubsetOf (dotnetclass "AppDomain").CurrentDomain.PermissionSet

does it work for you?
 
  01 January 2013
Originally Posted by denisT: that's what some guy suggests http://social.msdn.microsoft.com/Fo...4-bc534bbb03b4/
looks reasonable.
here is a translation do the maxscript:

  directoryName =  @"c:\temp" -- for example
  permissionSet = dotnetobject "System.Security.PermissionSet" (dotnetclass "System.Security.Permissions.PermissionState").None
  writePermission = dotnetobject "System.Security.Permissions.FileIOPermission" (dotnetclass "System.Security.Permissions.FileIOPermissionAccess  ").Write directoryName
  permissionSet.AddPermission writePermission
  permissionSet.IsSubsetOf (dotnetclass "AppDomain").CurrentDomain.PermissionSet
  

does it work for you?

Of course it works perfectly. Thanks Denis, for now that problem is solved
I try to check
isDirectoryWriteable @"c:\temp"
 -- true
 -- but when I use 
 isDirectoryWriteable @"c:\temp\"
 --false

That's the reason why i used dotnet Directory methods.
Tell me it's my concept struct good solution or bad for Copy - Repath process. I first time try mapPaths struct so...
__________________
Looking in the right side. [bgaTools]
 
  01 January 2013
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:48 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.