PDA

View Full Version : New Article on Lonerobot.com - Automating Photoshop with DotNet and Com Interop


LoneRobot
04-24-2009, 12:02 AM
Hello Peeps,

A while back there was this (http://forums.cgsociety.org/showthread.php?f=98&t=754063)post about whether it is possible to save out multiple render passes from 3dsMax into PSD format. It got me thinking and after a bit of research I came up with the following information -

http://www.lonerobot.com/images/photoshop/psthumb.jpg (http://lonerobot.net/?p=374)



(http://www.lonerobot.com/dotnetarticles.html)[/url][url="http://lonerobot.net/?p=374"]http://lonerobot.net/?p=374
(http://lonerobot.net/?p=374)
hope you find it useful!

MarcoBrunetta
04-24-2009, 01:33 AM
Very useful! You have my thanks sir

PEN
04-24-2009, 12:51 PM
Pete, that is fantastic, I don't know how you get the time to do all this but thanks for finding the time.

LoneRobot
04-24-2009, 01:18 PM
Hi Paul, Marco!

thanks a lot, you're welcome.

As for finding time, I just do it while everyone else sleeps. :surprised I'm getting married in three months, I'm supposed to be planning that, not geeking around! EeeeeK!!!

IkerCLoN
04-24-2009, 01:37 PM
Why are you calling eek? :-P

Thanks for the document. It's fully understable even by a beginner like me! Thanks for sharing your knowledge (and your sleeping hours) with us :)

And congrats on the wedding!

LoneRobot
04-24-2009, 01:45 PM
Why are you calling eek? :-P



i'd like to point out, i'm not getting married to Charles L. :)

cheers Iker!

Gravey
04-24-2009, 01:58 PM
dude this is sweet! COM stuff in .NET is a big deal!

is there a way to do the same sort of thing via maxscript without using visual studio and the whole 'add reference' thing?

LoneRobot
04-24-2009, 02:09 PM
is there a way to do the same sort of thing via maxscript without using visual studio and the whole 'add reference' thing?

Hey Joel,

Im sure you can build an interop assembly without visual studio if that's what you meant, but If you mean actually using the COM object without a wrapper assembly then im not sure. It's something I've been looking into for a while, as I used a COM assembly with the work I did on getting the 3dsmax file thumbnail via Dotnet (http://www.lonerobot.com/thumb.html). I'm not 100% exactly how max does things sometimes with DotNet!

I talked briefly about this in the article, but you can only get so far with using the COM assembly in max. With both times i tried, at some stage max returns "system._COMobject" when instantiating a class, instead of the object i was expecting (in this case a photoshop document) I couldn't find a workaround unfortunately. If anyone else has an idea what is going on with this I'd be eternally grateful!

MarcoBrunetta
04-24-2009, 03:50 PM
Hi Paul, Marco!

thanks a lot, you're welcome.

As for finding time, I just do it while everyone else sleeps. :surprised I'm getting married in three months, I'm supposed to be planning that, not geeking around! EeeeeK!!!

Congrats mate!!

LoneRobot
04-24-2009, 03:55 PM
thanks marco! She is aware of my geekery too, and still wants to get married! :thumbsup:

PEN
04-24-2009, 04:37 PM
Congrats Pete, no wonder you have time, no wife, no kids, that takes up half of every day for me.

LoneRobot
04-24-2009, 07:27 PM
ha ha! I can believe it! Looks like i'll have to get a few articles in quick!

JHN
04-24-2009, 08:29 PM
See that's why my website is lacking severely, the last years ;)
Happily married, 2 kids and one more on the way and a regular demanding day job. I still have a tutorial in the pen for reusing a extensible tool framework I use a lot. But stuff like that takes so much time. When it's half past eleven it's lights out for me... and I'm like 30... :blush:

So, goodnight :wavey:

-Johan

PiXeL_MoNKeY
04-24-2009, 08:56 PM
Gravey, you could doing it using Python instead. Here (http://techarttiki.blogspot.com/2008/08/photoshop-scripting-with-python.html) is an article over at Tech Art Tiki on using Python with Photoshop. The Article also has a link to presentations on using 3ds Max and Python together.

-Eric

LoneRobot
04-25-2009, 12:00 AM
hi eric,

i love that python resourse, the greatest thing about it all is that i've never coded python but it all made sense to me for some reason! the adobe DOM seems to be the same regardless of language. You just have to adapt the syntax slightly but essentially it's the same.

hey johan, seems to me that you need to read your kids some WPF stuff at bedtime instead of normal stories, that way when Max integrates that as standard you'll have couple of XAML experts in house :bowdown:

Gravey
04-25-2009, 07:17 AM
Gravey, you could doing it using Python instead. Here (http://techarttiki.blogspot.com/2008/08/photoshop-scripting-with-python.html) is an article over at Tech Art Tiki on using Python with Photoshop. The Article also has a link to presentations on using 3ds Max and Python together.Cheers, I have already been using python to control photoshop, think i've read that article too but thanks just the same.

If I were able to do the same thing in .NET via maxscript it'd just simplify things by keeping it in a single language without external dependencies. Not a big deal though. If a client needs a .NET solution I can just follow Pete's examples! Thanks again Pete and congrats (forgot to say in earlier post) ;)

LoneRobot
04-25-2009, 11:16 AM
If I were able to do the same thing in .NET via maxscript it'd just simplify things by keeping it in a single language without external dependencies. Not a big deal though. If a client needs a .NET solution I can just follow Pete's examples! Thanks again Pete and congrats (forgot to say in earlier post) ;)
:thumbsup: thanks fella

I totally understand where you are coming from, It would be nice to be able to set this up entirely via MXS but i really think it would be more trouble than it is worth. You'd have to build the interop assembly at runtime, and then you are faced with the option of having to use the methods expected by the com object. These, from what i can see are not obvious if the selection example is anything to go by.

It was asking for a multidimensional array (cast into a generic system.object) of 4 coordinate integer arrays, each array also has to be cast into a generic system.object in order for it to work!! :banghead: The wrapper at least allow you to make the instances of weird syntax a little easier to swallow at the end level by handling them the way you want.

For example, to my class I just added this method -
MarqueeSelect(ByVal X As Integer, ByVal Y As Integer, ByVal Width As Integer, ByVal Height As Integer)
that's got to be better than trying to set up and provide the example of integer arrays above! so to make a selection on the current document in photoshop via max, you are just calling a rectangle structure - x,y is the top corner and followed by a height and width,
PhotoShop.MarqueeSelect 50 46 200 400
It shouldn't be to hard to set up similar for the rest of the functions like the adjustments and filters too.

I've spent a few hours looking into the COM/reflection object issue and trying to use gettype().invokemember from Max, and it has done my head in!

JHN
04-26-2009, 08:52 AM
hey johan, seems to me that you need to read your kids some WPF stuff at bedtime instead of normal stories, that way when Max integrates that as standard you'll have couple of XAML experts in house :bowdown:

Tried that with my wife already, but that didn't work out very well, but maybe you're right and the kids are more receptive for this sort of stuff... :thumbsup:

-Johan

LoneRobot
05-03-2009, 02:05 PM
Hello All,

Just posted an update to the PhotoShop control library. It now contains the following methods -
http://www.lonerobot.com/images/photoshopbotmethods.png (http://lonerobot.net/?p=374)

article is as before, here (http://lonerobot.net/?p=374)

Vsai
05-03-2009, 03:11 PM
nice bloody work pete.

Thanks for taking the time!

LoneRobot
05-03-2009, 05:13 PM
cheers dave,

I've actually updated it further since my initial post earlier, there are now even more functions exposing a few common photoshop operations.

LoneRobot
05-13-2009, 08:45 PM
Hello Again,

Just posted another update to the PhotoShop control library. It now contains classes to access various image types in order to automate saving a compositon to other filetypes -


http://www.lonerobot.com/images/photoshopmethods2.jpg (http://lonerobot.net/?p=374)


article is as before, here (http://lonerobot.net/?p=374)

drdubosc
05-13-2009, 09:44 PM
Wow. Turn my back for a couple of weeks, and all this has happened! Thanks LR, especially for the COM wrapper stuff.

LoneRobot
05-14-2009, 09:23 AM
hi dr, you're welcome, nice to have you back!

LoneRobot
06-11-2009, 10:39 PM
Another Update! -

I have integrated a function encapsulating the Action Descriptor - this means I can now set up pretty much anything into the assembly. I've added a hatload of new filters and a few more methods. This upgrade now paves the way to integrate whatever custom function you wanted, easilly called from 3dsmax.

http://www.lonerobot.com/images/photoshopmethods3.jpg

If you've not seen the new blog layout, take a look, I think it's much better now with the increased number of articles.

http://lonerobot.net/?p=374

Zbuffer
06-12-2009, 07:51 AM
WoW !!!
Really interesting, thx a lot LoneRobot,

On a side note, how do you make these nifty images describing your classes ?

LoneRobot
06-12-2009, 08:33 AM
it's not something you'll find in the express edition unfortunately - its called the class diagram

http://cs.vbcity.com/blogs/kulrom/archive/2009/02/28/how-to-use-the-class-view-window-and-class-diagrams.aspx

Zbuffer
06-13-2009, 12:06 AM
Hi, yes, I know the class diagram, but I meant how to change the colors ?

LoneRobot
06-13-2009, 04:52 AM
Photoshop ;)

CGTalk Moderation
06-13-2009, 04:52 AM
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.