Bug in rolloutCreator in max 2012
I've found strange error in max 2012 - something changed in rolloutCreator struct.
not working (it works in 2009):
cs="print \"spinner changed...\""
rc=rolloutCreator "myrollout" "Test rollout"
rc.begin()
rc.addcontrol #spinner "somespinner" "My spinner"
rc.addhandler "somespinner" #changed paramstr:"val" codestr:cs
createdialog (rc.end())
and solution: just add space to the end of paramstr string - paramstr:"val ".
No infocenter toolbar
If you don't use Infocenter there is a way how to close it. Just download this script and put it to your ..\Scripts\Startup\ directory. (usually c:\Program Files\Autodesk\3ds Max 2012\Scripts\Startup\). Enjoy!
DOWNLOAD
wpf 3d from maxscript
Ok, first 3d wpf demo is here. It has many limitations (now) but it's working and it's possible to save result to xaml file.
TODO: correct smoothing (now whole object is smoothed), add mapping, materials...
It's just a sample of how it is possible.
dotNet.loadAssembly @"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll"
dotNet.loadAssembly @"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Workflow.ComponentModel.dll"
dotNet.loadAssembly @"c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll"
rollout rl "wpf 3d"
(
dotnetcontrol wpfwindow "System.Windows.Forms.Integration.ElementHost" width:(rl.width-15) height:(rl.height-15) align:#center
fn dnpoint p=
(
dotnetobject "System.Windows.media.media3d.point3d" p.x p.z -p.y
)
fn dnvector p=
(
dotnetobject "System.Windows.media.media3d.vector3d" p.x p.z -p.y
)
fn dnmesh3d obj=
(
wpfmesh=dotnetobject "System.Windows.media.media3d.MeshGeometry3d"
o=snapshotAsMesh obj
nv=o.numverts
for i=1 to nv do
(
v=meshop.getVert o i
wpfmesh.positions.add(dnpoint v)
)
for i=1 to o.numfaces do
(
f=getface o i
wpfmesh.TriangleIndices.Add(f.x-1 as integer)
wpfmesh.TriangleIndices.Add(f.y-1 as integer)
wpfmesh.TriangleIndices.Add(f.z-1 as integer)
)
wpfmesh
)
fn dncamera c=
(
wpfcam=dotnetobject "System.Windows.media.media3d.perspectivecamera"
wpfcam.position=dnpoint c.pos
wpfcam.lookdirection=dnvector -c.dir
wpfcam.fieldofview=c.fov
wpfcam.FarPlaneDistance=50000
wpfcam
)
fn wpfcolor col=
(
colors=dotnetclass "system.windows.media.color"
colors.fromargb col.a col.r col.g col.g
)
fn wpfdiffusematerial col=
(
wpfbrush=dotnetobject "system.windows.media.solidcolorbrush"
wpfbrush.color=wpfcolor col
wpfmat=dotnetobject "System.Windows.media.media3d.diffusematerial"
wpfmat.brush=wpfbrush
wpfmat
)
fn wpfgeometrymodel3d MeshGeometry3D mat=
(
dotnetobject "System.Windows.media.media3d.geometrymodel3d" meshGeometry3D mat
)
fn wpflight l=
(
col=classof l
out=undefined
case classof l of
(
(Omnilight):
(
out=dotnetobject "System.Windows.media.media3d.pointlight" (wpfcolor l.color) (dnpoint l.pos)
)
(TargetDirectionallight):
(
out=dotnetobject "System.Windows.media.media3d.directionallight" (wpfcolor l.color) (dnvector l.dir)
)
(freeSpot):
(
out=dotnetobject "System.Windows.media.media3d.spotlight" (wpfcolor l.color) (dnpoint l.pos) (dnvector l.dir) l.falloff l.hotspot
)
)
out
)
fn saveXAML wpfelementhost=
(
filename=getSaveFileName caption:"Save XAML to:" types:"XAML|*.xaml"
if filename!=undefined then try
(
fs=dotnetobject "System.IO.Filestream" filename (dotnetclass "system.IO.FileMode").Create
xamlw=dotnetclass "System.Windows.Markup.XamlWriter"
xamlw.save wpfelementhost.child fs
fs.close()
)
catch
(
messagebox ("Saving error: "+getCurrentException())
)
)
fn btnsaveclick=
(
savexaml wpfwindow
)
on rl open do
(
wpfbrush=dotnetobject "system.windows.media.solidcolorbrush" ((dotnetclass "system.windows.media.colors").white)
lab=dotnetobject "System.Windows.Controls.label"
lab.content="wpf 3d demo by maxscriptfactory.com"
lab.foreground=wpfbrush
spanel=dotnetobject "System.Windows.Controls.StackPanel"
wpfwindow.child=spanel
v3d=dotnetobject "System.Windows.Controls.viewport3d"
v3d.width=750
v3d.height=500
cam=dncamera cameras[1]
v3d.camera=cam
mg=dotnetobject "System.Windows.media.media3d.model3dgroup"
for l in lights do
(
wpfl=wpflight l
if wpfl!=undefined then mg.children.add(wpfl)
)
for o in geometry do
(
scena=dnmesh3d o
model=wpfgeometrymodel3d scena (wpfdiffusematerial o.wirecolor)
mg.children.add(model)
)
modelvis=dotnetobject "System.Windows.media.media3d.modelvisual3d"
modelvis.content=mg
v3d.children.add(modelvis)
spanel.children.add(v3d)
spanel.children.add(lab)
butsave=dotnetobject "System.Windows.Controls.Button"
butsave.content="save xaml"
spanel.children.add(butsave)
dotNet.addEventHandler butsave "Click" btnsaveclick
)
)
createdialog rl width:800 height:600
3ds max change priority utilities
Two simple utilities for download:
3dsmaxBelNormAff-2.exe - red icon - changes priority of 3dsmax.exe to "very low" and removes affinity to first two CPU cores.
3dsmaxBelNormAffFULL.exe - yellow icon - changes priority of 3dsmax.exe to "very low" and set affinity to all cores.
Source code is very simple; everything on the six lines: (VB.net, console application, this is 3dsmaxBelNormAff-2 example)
Sub Main()
Dim p() As Process
p = Process.GetProcessesByName("3dsmax")
For Each i As Process In p
i.PriorityClass = ProcessPriorityClass.Idle
i.ProcessorAffinity = i.ProcessorAffinity.ToInt32 And Not 3
Next
End Sub
Download
Saving generated wpf content to xaml file (maxscript function)
This function will be very useful later with WPF 3D. First step to designing 3d applications in 3dsmax.
Parameter "wpfelementhost" is dotnetcontrol wpfframe "System.Windows.Forms.Integration.ElementHost" filled with content.
fn saveXAML wpfelementhost=
(
filename=getSaveFileName caption:"Save XAML to:" types:"XAML|*.xaml"
if filename!=undefined then try
(
fs=dotnetobject "System.IO.Filestream" filename (dotnetclass "system.IO.FileMode").Create
xamlwriter=dotnetclass "System.Windows.Markup.XamlWriter"
xamlwriter.save wpfelementhost.child fs
fs.close()
)
catch
(
messagebox ("Saving error."+getCurrentException())
)
)