technical architecture.

utility

Recursive Tiff to PDF

by on Apr.01, 2010, under Admin, Batching, utility

Another one of those semi random requests that turned out to be more of a pain in the arse than it really should be. the mission: Converting a large mass of scanned tiff CAD drawings into multi page PDF’s

There are two ways to do this fairly quickly, the easy way if you don’t have many individual sets to work with is to simply drag all the tif images into the window in Acrobat Pro and save the file from there.

If however, like us, you have to convert 42 gigs or so of tiff’s spread across 204 folders and group the PDF’s by the folders, you can programmatically do it via some batch scripting and the use of a few free command line utilities from the internet.

First thing to do is convert each individual TIF file to a PDF, for this, we use Imagemagick this is a tool that can do many things but we’re really just going to abuse the ‘convert’ application for now.

After installation, you can then in the dos prompt type ‘convert file.tif file.pdf’

For our purposes we want to convert ALL of the files, so we can set it up in a recursive for loop using

Saved into a file “Convert all Tiffs in Subdirectory to PDFs.bat” or something equally exciting:
FOR /R %%a IN (*.tif) DO convert "%%a" "%%a.pdf"

After that is done we will use a second utility to ‘join’ the pdf’s the PDF toolkit

With this util we can modify pdf files quickly; we’ll use the Append function

pdftk *.pdf cat output combined.pdf

This will concatenate all pdf’s in the current directory and write them into ‘combined.pdf’ in the same directory. Great!

To expand this into a large subdirectory we do a little more batch scripting

The below is saved into a file “Join all PDF in directory tree.bat”

FOR /F "delims=" %%a in ('DIR /S /B /AD ^|SORT') DO (
CD "%%a"
pdftk *.pdf cat output "%%a_joined.pdf"
)

This will output a combined PDF for each of the individual directories.

A good time was had by all.

Imagemagick looks to have quite a few useful applications and will warrant some more exploration soon.

1 Comment more...

Revit->FBX->Max, Collapsing large numbers of meshes

by on Mar.15, 2009, under Architecture, Batching, maxscript, Scripting, utility

Well, lets just say that dealing with large Revit files can get a little ugly for visualization purposes to say the least. there are several fundamental issues currently, ranging from workflows in building usable familys inside of revit, to dealing with the geometry after the fact for rendering.

I had the pleasure to again deal with a fairly large Revit model. It only weighed in at about 300mb to start! for working on final renderings thats all well and good, and not a real issue to deal with, but for mid project progress renders it can get a bit painful doing a lot of the deconstruction needed to make it useful to work in in 3dsMax. spending several hours ‘cleaning’ a revit model in max so that you can get any sort of rendering done is lets say, a bit depressing, when you know you’ll have to do the same process again in 2 weeks.

all that said, I started looking for some solutions to one small facet of the problem, and found some good case study testing on efficiently attaching a ton of meshes done by Dave Stewart and also a fair number of tips from the Maxscript crew at CGTalk

So I did a  small adaptation of Dave’s attachment script above, which can be found here: CollapseSelected-inParts5.ms Its not pretty, but we’ll get there soon enough.

It takes your current selection, and simplifies the number of objects by the square root (Dave’s tested optimal amount for speed collapsing!) its a work in progress, and i figure i’ll take this, combined with set of other tools for collapsing either by Selected Material, Similar Objects+Instances, Layer, and some name filtering. that should take the day long revit cleanup jobs and compress them down to an hour or so.

Yay.

2 Comments more...

Mass Exporting, again

by on Feb.24, 2009, under Batching, maxscript, utility

Mass exporting..

We have a fun little virtools app that loads in various NMO’s exported out from max on the fly as needed based on user input, so in the process of working out what our process would be, we came to the need to have each seperate 3dsmax hierarchy exported out into a seperate virtools NMO file.

Pretty simple, but the question came up on a forum today and its been a useful little script that I’ve been using for years now.

the guts are:

 
--wanky recursive function to parse hierarchy into an array
fn addChildrenToArray theChildren currentObjsToExport =
(
	for c in theChildren do
	(
		append currentObjsToExport c
		addChildrenToArray c.children currentObjsToExport
	)
)
 
fn massExportfn hier path filetype =
(	
 
	exportSelection = selection as array
	if hier == true then
	(
		baseNodesToExport = for o in exportSelection where o.parent == undefined collect o
	)
	else baseNodesToExport = exportSelection
 
	--parse through said root nodes
	for o in baseNodesToExport do 
	( 
		oldPos = o.position
		o.position = [0,0,oldPos.z]
 
		--children returns a 'NodeChildrenArray, so convert that to an array manually.
		--include the current node in the array no matter what.
		currentObjsToExport = #(o)
 
		-- if we're packaging hierarchys then collect childrem
		if hier == true do
		(
			addChildrenToArray o.children currentObjsToExport
		)
 
		select currentObjsToExport		
 
		--random info for use to ogle at the export.. yea yea
		format "\tExport:\t%\tas\t%\n"  o.name filetype
		format "\tTo:\t%\n" (path + "/" + o.name + filetype)
		format "\n-----------------------------\n\n"
 
		-- if we need to save selected use this export type
		if filetype == ".MAX" then
		(
			savenodes currentObjsToExport (path + "/" + o.name + filetype) quiet:true
		)
		else
		(
			--export using the name of the root node as the filename
			exportfile (path + "/" + o.name + filetype) #noPrompt selectedOnly:true 
		)
		o.position = oldPos
	)
	select exportSelection
)
 
-- and its used by:
massExportfn true "C:/temp/" ".vmo"

Theres an interface for it here, but i’ve got it built into many other small little pipeline specific utils, so that may not be of any real use to anyone else, but this little snip might be useful for someone out there.

Leave a Comment more...

Maxscript: ServerUtilities v0.5 beta

by on Dec.07, 2008, under Admin, Batching, maxscript, utility, vray

This handles the services perfectly for me here, I’m doing a little more work on it to support using the server.exe and vrayspawner exe versions as well, but that wont be finished for a while as its a spare time project. I’m really looking for feedback in terms of platforms you’re looking to use it on, and what features would be nice to see in addition.


Click here to Download

Install is pretty straightforward, simply unzip into your Scripts directory.. after a bit more testing for various people I’ll throw together an installer, but for now its slightly manual.

after you unzip it, assuming your max is installed in say, C:\3dsmax08\ you should see several files

Maxscript files: Access them as Maxscript Pulldown, Run Script.
C:\3dsMax08\server_tool_lite_05.mcr — Run this to install the script into the Customize UI, under category dbScripts.
C:\3dsMax08\ServerUtilities\server_tool_lite_05.ms — Run this to try out the tool without installing it into the Customize ui..

C:\3dsMax08\ServerUtilities\… There will be a few other exe’s in this directory, mostly commandline utilities that the script calls to batch modify things.

After you run the script the first time, it will create a file C:\3dsMax08\ServerUtilities\ServerToolLite.ini which will save your settings. In the script, it might be easier for you to add 1 server, and then browse to the ServerToolLite.ini file and manually add the other 19 servers in notepad.

Cheers,
Dave

2 Comments :, more...

3dsmax DirectX oddity

by on Nov.25, 2008, under maxscript, utility

Basic Problem: IT has enforced a Screensaver password policy here now Now, with the D3D view port driver, when you come back from a locked workstation, it doesn’t always instantiate the DX display correctly. we’re noticing on our workstations that it will come back working to a point.. IE: All of the geometry on screen is selectable, but only ~20% of it is displayed with edges in max.

a hack to fix it without having to restart max every time the computer locks on you, I’ve found i can Disable and then Enable the Direct3D Cached meshes.. this works.. in a crappy sort of way.

Here’s some code that toggles the d3d cached.. it also helps to show how to access things in max that are not readily open to the maxscript language, by using windows messaging to “push” buttons on dialogs! most credit to Richard at cgtalk!

 
toolTip="toggle the Use Cached D3DXMeshes Viewport"
buttonText="toggle the Use Cached D3DXMeshes Viewport"
 
--start macro
 
-----------------------------------------------------------------------------------------------
--
-- toggles the "Use Cached D3DXMeshes" checkbox of the Viewport configuration
--
-----------------------------------------------------------------------------------------------
 
--diable it while
 dialogMonitorOps.enabled = false
 global prefsDialog_hwnd = undefined
 global retMessage=""
 fn toggleCachedD3DMeshes = (
 
	 --Constants for sendMessage method	
	local BM_GETSTATE = 0xF2
	local BM_CLICK = 0xF5
	local BM_SETCHECK = 0xF1
	local BST_CHECKED = 0x1	 
 
 	local hwnd = dialogMonitorOps.getWindowHandle()
 	local dialogTitle = uiAccessor.getWindowText hwnd
 	if (dialogTitle != undefined) then (
 		if (dialogTitle == "Preference Settings") then (
			prefsDialog_hwnd = hwnd
			format "We're in the preferences dialog\n" 
			local hwnd_children = uiAccessor.getChildWindows hwnd
 			for i = 1 to hwnd_children.count do (
 				local hwnd_child_title = uiAccessor.getWindowText hwnd_children[i]
				if (findString hwnd_child_title "Configure Driver..." == 1) then (
					format "found config button... pressing\n"
					local hwnd_config = hwnd_children[i]
 					uiAccessor.pressButton hwnd_config
					)
				)
			)
		else if (dialogTitle == "Configure Direct3D") then (
			local hwnd_children = uiAccessor.getChildWindows hwnd
 			for i = 1 to hwnd_children.count do (
 				local hwnd_child_title = uiAccessor.getWindowText hwnd_children[i]
				if (findString hwnd_child_title "Use Cached D3DXMeshes" == 1) then (
					format "found the cached button\n"
					local hwnd_cached = hwnd_children[i]
					local CheckState = windows.sendMessage hwnd_cached BM_GETSTATE 0 0
					local IsChecked = bit.get CheckState BST_CHECKED
					format "the checkbox was: %\n" IsChecked
					-- Uncheck it
					if IsChecked then
					(
						windows.sendMessage hwnd_cached BM_CLICK 0 0
						windows.sendMessage hwnd_cached BM_SETCHECK 0 0
						format "Cached D3DXMeshes has been disabled.\n"
						format "Pressing OK on the ConfigureD3D page\n"
						uiAccessor.sendMessageID hwnd #IDOK
						format "Pressing OK on the Preferences page\n"
						uiAccessor.sendMessageID prefsDialog_hwnd #IDOK
						retMessage="Turning the CachedD3DXMeshes *OFF*"
					)
					-- Check it
					else if not IsChecked then
					(
						windows.sendMessage hwnd_cached BM_CLICK 0 0
						windows.sendMessage hwnd_cached BM_SETCHECK 1 0
						format "Cached D3DXMeshes has been enabled.\n"
						format "Pressing OK on the ConfigureD3D page\n"
						uiAccessor.sendMessageID hwnd #IDOK
						format "Pressing OK on the Preferences page\n"
						uiAccessor.sendMessageID prefsDialog_hwnd #IDOK
						retMessage="Turning the CachedD3DXMeshes *ON*"
					)
 				)
 			)
 		)
 	)
	true
 
 )
 
fn toggleUseCache =
(
	dialogMonitorOps.interactive = false
	dialogMonitorOps.unregisterNotification id:#setD3DCache
	dialogMonitorOps.registerNotification toggleCachedD3DMeshes id:#setD3DCache
	dialogMonitorOps.enabled = true
	--run it
	max file preferences
	--disable it!
	dialogMonitorOps.enabled = false
	dialogMonitorOps.unregisterNotification id:#setD3DCache
	--messagebox retMessage
)
 
toggleUseCache()
format retMessage
Leave a Comment :, , more...

Maxscript: Grid by Name

by on Nov.07, 2008, under Architecture, maxscript, utility

Here’s a useful one i made in 2003, one of my first scripts actually! posting it up because i find myself using it ~60 times a day on this current project with curved/angled bits all over it!

A Helper dialog to speed up working with custom Grids. Helps immensely in the workflow of angular modeling (read: silly modern architecture) when combined with a hotkey to create grid and autogrid >:)

Basics: It populates the dialog with all current grids in the scene, including the HomeGrid. you can double click on any grid to activate that, also has buttons to change the view to match the grid, and to select the current active grid. also includes a cycle of the Toolmodes (View/World/Parent/Screen/Local/Gimbal/Grid)

— if there are no grids in the scene, then toggle between the toolmodes
— if there is just 1 grid in the scene, toggle between it and the Home Grid
— if there are grids in the scene, open the window
— if there are grids in the scene and the window is already open, toggle between the grids

1 Comment :, , more...

working :)

by on Oct.04, 2008, under python, utility

yay, all the right clickies work.

9 Comments :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!