SVG polygon render
Hey.
I am trying to render out a SVG file from my 3Ds max scene and I got some problems.
I am no scripter at all, and just know some pretty basic stuff - so I have used this site to find the script:
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/20...
When I use this script, I get an error I dont know how to fix.
Problem:
-- Error occurred in ColorToHex(); filename: ; position: 71; line: 4
-- Frame:
-- theComponents: undefined
-- theValue: undefined
-- col: undefined
-- called in f loop; filename: ; position: 1807; line: 60
-- Frame:
-- theZDepth: -144.292
-- v1: [496.63,453.812,4.86606e+009]
-- v2: [680.611,300.67,4.86615e+009]
-- theLitFillColor: undefined
-- f: 3
-- v3: [506.527,195.721,4.86622e+009]
-- theNormal: [0,0,1]
-- theFace: [5,6,8]
-- theFaceCenter: [1.87392,-7.60636,37.7282]
-- called in o loop; filename: ; position: 1876; line: 64
-- Frame:
-- theStrokeColor: (color 255 255 255)
-- o: $Box001
-- theFillColor: (color 28 28 177)
-- theMesh: TriMesh
-- called in anonymous codeblock; filename: ; position: 1891; line: 65
-- Frame:
-- theViewSize: [1050,584]
-- ColorToHex: ColorToHex()
-- compareFN: compareFN()
-- st: 55598317
-- theViewScale: [1.02539,0.570313]
-- theSVGMap: undefined
-- theBitmap: undefined
-- drawArray: #()
-- theSVGfile:
-- theStrokeThickness: 1
-- theViewTM: (matrix3 [0.707107,0.353553,-0.612372] [-0.707107,0.353553,-0.612372] [0,0.866025,0.5] [0,0,0])
-- theViewTM2: (matrix3 [0.707107,0.353553,-0.612372] [-0.707107,0.353553,-0.612372] [0,0.866025,0.5] [1.24123,-12.3235,-166.667])
-- theFileName: "C:\Users\Iwill ecowork\AppData\Local\Autodesk\3dsMax\2014 - 64bit\ENU\scripts\PolygonRendering01.svg"
-- Unknown property: "r" in undefined
Here is the script:
(
fn ColorToHex col =
(
local theComponents = #(bit.intAsHex col.r, bit.intAsHex col.g, bit.intAsHex col.b)
local theValue = "#"
for i in theComponents do
theValue += (if i.count == 1 then "0" else "") + i
theValue
)
fn compareFN v1 v2=
(
if v1[6] < v2[6] then -1 else 1
)
local st = timestamp()
local theFileName = (getDir #userscripts + "\\PolygonRendering.svg")
local theSVGfile = createFile theFileName
format "\n" to:theSVGfile
local theViewTM = viewport.getTM()
theViewTM.row4 = [0,0,0]
local theViewTM2 = viewport.getTM()
local theViewSize = getViewSize()
local theViewScale = getViewSize()
theViewScale.x /= 1024.0
theViewScale.y /= 1024.0
local drawArray = #()
local theStrokeThickness = 1
gw.setTransform (matrix3 1)
for o in Geometry where not o.isHiddenInVpt and classof o != TargetObject do
(
local theStrokeColor = white
local theFillColor = o.wirecolor
local theMesh = snapshotAsMesh o
for f = 1 to theMesh.numfaces do
(
local theNormal = normalize (getfaceNormal theMesh f)
if (theNormal*theViewTM).z > 0 do
(
local theFace = getFace theMesh f
local v1 = gw.transPoint (getVert theMesh theFace.x)
local v2 = gw.transPoint (getVert theMesh theFace.y)
local v3 = gw.transPoint (getVert theMesh theFace.z)
v1.x /= theViewScale.x
v1.y /= theViewScale.y
v2.x /= theViewScale.x
v2.y /= theViewScale.y
v3.x /= theViewScale.x
v3.y /= theViewScale.y
local theFaceCenter = meshop.getFaceCenter theMesh f
local theZDepth = (theFaceCenter*theViewTM2).z
append drawArray #(v1, v2, v3, (ColorToHex theStrokeColor), (ColorToHex theLitFillColor), theZDepth)
)--end if normal positive
)--end f loop
)--end o loop
qsort drawArray compareFN
for d in drawArray do
(
format "\t\n" d[4] d[5] theStrokeThickness to:theSVGfile
)
format "\n" to:theSVGfile
close theSVGfile
local theSVGMap = VectorMap vectorFile:theFileName alphasource:0
local theBitmap = bitmap theViewSize.x theViewSize.y
renderMap theSVGMap into:theBitmap filter:true
display theBitmap
format "Render Time: % sec.\n" ((timestamp()-st)/1000.0)
)
Thanks a lot for the help.
Comments
Hi there , can have the
Hi there , can have the script please i cant find no more
thanks