[Closed] Export vector from photoshop to 3dsmax
there is an easy way to export vector layer from photoshop and import each layer in seperate spline?
yes, there is. you have to just simply clap your hands and say “abracadabra”…
talking seriously it must be a way to export Adobe vector splines to Illustrator format.
max has an importer from Illustrator. at least i remember that i read splines (fonts) created in Illustrator to Max.
3ds Max can import .ai files from Illustrator if you save them as version 8.0 (newer versions aren’t supported.
“abracadabra”…
owoo its work! im going to home and relax!
i know we can export to AI and import in max, i did , im looking to way to export every layer (shape)from photoshop to seperate objects(Spline) in max.
is there a way to write photoshop vector data and layer data in text file? so i can remake it in max?
shazam!!! watch from about 1m 25, if you get bored with the start bit. Download the assembly at the end of the article.
tested with CS3
Here’s a (hack) way to do what you’re referring to, and it won’t totally work without a TON of elbow grease:
First, max’s BitmapLayerManager can only load bitmap data, to my knowledge. This means max can’t load spline data from photoshop, only pixels.
Method#1: Considering this, we could convert a spline’s anchor points into opaque pixels, and then load that bitmap image containing the “anchor points” into max, query for the transparency of each pixel, and then build spline points from pixels that are not transparent.
One thing that is missing in this idea is how to transfer the bezier handle values, which will be lost. What you’ll get from the above idea is a spline shape that has no curve between the points, but is rather straight. The bitmapLayerManager cannot retrieve these bezier handle values, which probably exist in the actual file data.
Method#2: You could take this hack further by rasterizing the spline in fotochop with a transparent background, opening the PSD with bitmapLayerManager in max, and then building a spline point/anchor for every non-transparent pixel in the layer. This method would preserve the entire spline, but would introduce too many points/anchors in max (every pixel would be a spline anchor). But, you could do this for all layers in any given PSD file.
And if you have way too much time on your hands, you could use method #2 as a way to “grade” method #1. You could determine approximate values for the bezier handles by setting an initial guess as to the weight of a handle, and then compare the resulting curve to the spline loaded by method #2. Then based on the error in the guess, refine the handle’s weight until it matches (within episilon) of the spline shape loaded by method #2. I’m not sure how to get a spline anchor handle’s weight, or if that is even available to maxscript, so this may not work.
Alternatively, you could go with method #2 and then write code to reduce the spline points. However, you will be unable to determine what the original “anchor points” were, which is why the above paragraph presents a more accurate, albeit still approximate, possible solution.
Another alternative is to write a PSD parser that supports vectors/splines, which requires a reverse-engineering of the proprietary PSD or AI format. These formats are also actively being developed, so even if you wrote code to properly interpret an AI or PSD, the same code may not work when Adobe releases the next version of their software. And Adobe would probably be pretty upset, considering they own those proprietary formats. I’m going to guess that the reason Max doesn’t support AI files made after version 8 is due to licensing.
Here is some code that will open a PSD and build splineKnots from non-transparent pixels (I haven’t tested it so it may not work 100%).
(
local any_file = getOpenFileName caption:"Open PSD file" filename:(GetDir #scripts+"\\") types:"PSD(*.psd)|*.psd|"
if any_file != undefined then
(
local myLayersCount = BitmapLayerManager.getLayerCount anyFile
for i = 1 to myLayersCount do
(
local myFFbitmap = bitmapLayerManager.LoadLayer anyFile (i-1) true
--iterate over the pixels row by row using getpixels method.
for g = 0 to myFFbitmap.height by 1 do --for the height of the bitmap
(
local myPixelRow = getPixels myFFbitmap [0,g] myFFbitmap.width --get a row of pixels
for j = 1 to myPixelRow.count do --for every row of pixels
(
if myPixelRow[j] != (color 0 0 0 0) then --if the pixel isn't completely transparent
(
--build a spline knot/anchor/point from it
--use [g,j] as the [x,y] values for the spline to be built
local myPos = [g,j]
local ss = SplineShape pos:myPos
addNewSpline ss
addKnot ss 1 #corner #line myPos
updateShape ss
)
)
)
)
)
)
So in summary, you can convert pixels into splineKnots, but you can’t load splines directly from photoshop. You have to convert the paths to .AI version 8 to import, as mentioned already.
Hope this helps, if you read this far.