PDA

View Full Version : Maxscript editor tip/tutorial


JHN
01-07-2009, 01:33 PM
Hi everyone,

I made a small video tutorial about a thing I found very usefull in the maxscript editor, I haven't read anyone writing about it, but maybe I haven't looked enough, but here it is: http://public.subd.nl/screencasts/

Hopefully it's of any use.

-Johan

j-man
01-07-2009, 02:10 PM
Hey Johan,

didn't know that < : thanks for that!


J.

Mathieson
01-07-2009, 11:49 PM
That is one awesome time-saver. Thanks for sharing.

PEN
01-08-2009, 01:24 AM
That is fantastic, thanks for putting that up there.

PEN
01-08-2009, 01:37 AM
Just as a note, it is case sensitive.

Teirz
01-08-2009, 02:18 AM
That's a good way to keep scripts written in a consistent way!
Thanks!

JHN
01-08-2009, 08:34 AM
Thanks guys, it really shows how accustomed everyone was to the terrible, horrible old mxs editor, and we're probably so happy with a pretty decent editor (although I can come up with a feature or 2 one, like code completion) not a lot of people delved into the new options... at least not me.. until now that is... there are a lot more little gems hidden in the prefs file, like being able to open more then 10 files, multilinetabs etc... and I really wished the output pane could be used as a listener, so we could ditch the clumsy listener and have a streamlined window for editing and output.

-Johan

xenry
01-08-2009, 12:16 PM
a killer tip, man =)

steev
01-08-2009, 01:14 PM
speaking of improvements to the mxsEditor - with the klunky old one, i did enjoy opening scripts in multiple windows to compare them side-by-side. i can't really do this easily with the tabbed interface. i'd like the option to "float" one of the tabs or open multiple editors. if anyone knows how to do this & i'm just missing it, i'd appreciate the tip!

Mathieson
01-08-2009, 07:21 PM
A little tip to help with making it easier to format the abbreviations file.

Write the code as you normally would in a script, then using the replace tool (Ctrl+H) turn on the "Transform backslash expressions" checkbox (Alt+B) and perform find and replace on line breaks and tabs.

if EXPR then
(
EXPR
)
else
(
EXPR
)

If you use that chunk of code and then do a search and replace searching for "\n" and replacing with "\\n" (no quotations), it will insert a "\n" at the beginning of each new line.

Then do a search and replace using "\t" and "\\t" and it will replace all of the tab characters.

All thats left to do is a few button presses using the "End" and "Delete" keys and your abbreviation file is nicely formatted.

EDIT: I just did the search and replace with "\n" and "\\n" and this time it actually replaced the line breaks. Not too sure why it is leaving them in sometimes and sometimes not.

martroyx
01-08-2009, 08:46 PM
and I really wished the output pane could be used as a listener, so we could ditch the clumsy listener and have a streamlined window for editing and output.


totally agree ;)

Thank for the tip , very useful !!

JHN
01-08-2009, 10:31 PM
Maybe we should put up our abbreviations for other to have a look see.
Here are mine so far

/* COMMENTS */
menu=--@categorie:CAT;name:NAME;description:DESC
header=\n--******************************************************************************************************\n-- Created: 00-00-2009\n-- Last Updated: 00-00-2009\n-- Version: 0.10\n--\n-- Author : Johan Boekhoven / johan.boekhoven@gmail.com / subd.nl\n-- Version: 3ds max 2009 (10) (should work in older versions too!)\n--\n-- Discription: DESCRIPTION\n-- Usage: RUN IT\n--\n-- Wishlist:\n--\n--******************************************************************************************************\n-- MODIFY THIS AT YOUR OWN RISK\n
doc=/*\n<DOC> Description here.\nArguments:\n <bool> arg_a: A description of the argument.\nReturn:\n <bool> Function returns (anything?).\n*/

/* CODE STRUCTURES */
if=if ARG then\n(\n\tSTATE1\n) -- end if\nelse\n(\n\tSTATE2\n) -- end else
fn=fn NAME arg_a arg_b =\n(\n\tdoc\n\tfnBody\n)
str=struct NAME\n(\n\tVAR1,\n\tVAR2,\n\tfn\n)
fora=for in do\n(\n\t\n)\n
foraw=for in where ARG1 == ARG2 do\n(\n\t\n)\n
fori=for i = 0 to 100 do\n(\n\t\n)\n
foriw=for i = 0 to 100 where ARG1 == ARG2 do\n(\n\t\n)\n
foribw=for i = 0 to 100 by where ARG1 == ARG2 do\n(\n\t\n)\n
rol=rollout ""\n(\n\tbtn\n\tspn\n)\n

/* GENERIC */
start=menu header\n(\n\t\n)

/*CONTROLS*/
btn=button btn_ "" width: height: offset:[0,0] across:
pbn=pickButton pbn_ "" width: height: offset:[0,0] across:
spn=spinner spn_ "" width: range:[,,] type: offset:[0,0] across:
chb=checkButton chb_ "" width: height: offset:[0,0] across:
grp=group ""\n(\n\tbtn\n\tspn\n\tchb\n\tpbn\n)


Some are obviously specific for my needs, but maybe somebody can use it.
I think especially in the commenting and UI building and CA building department lot of speed can be gained by some well balanced abbreviations.

Has any also checked out the great work Rob is doing over at TAO and I try to follow the http://tech-artists.org/wiki/TAO:Code_Conventions, I think some public accepted abbreviations could help on good coding practice, but that's me.

@Mathieson, that's a really good tip!!

Cheers,
-Johan

martroyx
01-08-2009, 10:37 PM
do you know if it's possible to remap the shortcut , I don't find it very straight forward ??

coren
01-09-2009, 12:35 AM
you must edit the MXS_Editor.properties file.
To do this choose the option 'open global option file' from the tool menu.
Search the line '# User defined key commands'
and then add a line with your shortcut and the command you need.

you can find the explanation in the 'MAXScript Editor - Defining Custom Keyboard Shortcuts' tread, from the maxscript help

sorry for my english

cheers

martroyx
01-09-2009, 01:50 AM
Thank ! this work very well :applause:
the line to add is : Ctrl+?|IDM_ABBREV|

martroyx
01-09-2009, 07:06 AM
some dotnet one that I often use :rolleyes:


/* .NET */

dcol=(dotnetclass "system.drawing.color").fromargb 0 0 0
dstr=(dotnetobject "system.string" "")
darr=(dotnetclass "system.array")
darrr=(dotnetobject "system.array[]" 1)
dpt=dotnetobject "system.drawing.point" 0 0
dsize=dotnetobject "system.drawing.size" 0 0
dpad=dotnetobject "system.windows.forms.padding" 0 0 0 0
dpen=(dotnetobject "system.drawing.pen" (dotnetobject "system.drawing.solidbrush"((dotnetclass "system.drawing.color").fromargb 0 0 0)) 1)
dbrush=(dotnetobject "system.drawing.solidbrush" ((dotnetclass "system.drawing.color").fromargb 0 0 0))
stcp=(dotnetobject "system.windows.forms.columnstyle" (dotnetclass "system.windows.forms.sizetype").percent 50)
stca=(dotnetobject "system.windows.forms.columnstyle" (dotnetclass "system.windows.forms.sizetype").absolute 20)
strp=(dotnetobject "system.windows.forms.rowstyle" (dotnetclass "system.windows.forms.sizetype").percent 50)
stra=(dotnetobject "system.windows.forms.rowstyle" (dotnetclass "system.windows.forms.sizetype").absolute 20)

Zbuffer
01-09-2009, 09:55 AM
This thread is so usefull ;) Thx to all involved
Should be stickied !!!

j-man
01-09-2009, 02:30 PM
Ha Johan you've really hit upon a common note < :

FWIW I qwish we could open multiple script windows as well but i don't think it is possible.


J.

beam1
05-11-2009, 09:43 AM
wooow!this thread very useful for me!thanks a lot! :bowdown:

werwack
08-25-2009, 01:10 PM
Thanks for the tip. Indeed they are some interesting features in this editor compared to the old one (especially the multiple undo ;) )

Nevertheless I still prefer using Notepad++, this for 3 reasons:

when a word is selected, all the other occurences of it are highlighted. This seems light, but I just become addicted!
It is easy to open a document twice, to work at 2 different places at the same time (vertically unfortunately)
There is a good and smart compare feature
Beside I developed a small tool to easily manage and launch external files. All in all I am pretty happy with that.

JHN
11-23-2009, 10:20 PM
Hi everyone,

Triggered by another post, I decided to make a custom color scheme for mxs editor.
The tools>MXS_Userproperties are there to overwrite the default properties of the scintilla editor. With that in mind you can copy/paste the following in that file.


#~ Default font settings
font.base=font:DejaVu Sans Mono,size:10
font.comment=font:DejaVu Sans Mono,size:10
colour.code.comment.box=fore:#09C009,italics
colour.code.comment.line=fore:#09C009,italics

#~ Sets the color used for the caret (cursor).
caret.fore=#f92672
caret.line.back=#ff8800
caret.line.back.alpha=50

# Default
style.MAXScript.32=$(font.base),fore:#f92672,back:#272822
# White space
style.MAXScript.0=fore:#808080
# Comment: /* */.
style.MAXScript.1=$(colour.code.comment.box),$(font.code.comment.box)
# Line Comment: --.
style.MAXScript.2=$(colour.code.comment.line),$(font.code.comment.line),eolfilled
# Number
style.MAXScript.3=fore:#ae81ff
# String
style.MAXScript.4=fore:#e6db74
# Verbatim strings
style.MAXScript.5=fore:#007F00,$(font.monospace),back:#8AFB8A,eolfilled
# End of line where string is not closed
style.MAXScript.6=fore:#000000,$(font.monospace),back:#E0C0E0,eolfilled
# Identifiers
style.MAXScript.7=fore:#ffffff
# Operators
style.MAXScript.8=fore:#f92672,bold
# Keyword arg name
style.MAXScript.9=fore:#a6e22e
# Name value
style.MAXScript.10=fore:#e6db74
# Pathname
style.MAXScript.11=fore:#3F7F3F,$(font.monospace),back:#E0F0FF
# Keywords1 - Keywords
style.MAXScript.12=fore:#f92672,bold
# Keywords2 - Rollout controls
style.MAXScript.13=fore:#faaa3c,bold
# Keywords3 - Functions
style.MAXScript.14=fore:#0080ff
# Keywords4 - MXS Classes --Dotnet controls
style.MAXScript.15=fore:#ff8800
# Keywords5 - MAXClasses -- Node transform monitor
style.MAXScript.16=fore:#ff00ff
# Keywords6 - MAXSuperClasses modifier helper etc
style.MAXScript.17=fore:#ff0000
# Keywords7 - Core interfaces
style.MAXScript.18=fore:#00ff00,italics
# Keywords8 - Object sets
style.MAXScript.19=fore:#D0B080,italics
# Keywords9 - StructDefs
style.MAXScript.20=fore:#804020,italics
# Keywords10 - Const reserved globals true false undefined etc
style.MAXScript.21=fore:#4488ff,italics
# Keywords11 - Reserved globals
style.MAXScript.22=fore:#B00040
# Keywords12 - User defined
style.MAXScript.23=fore:#FF0000,bold,italics


This makes a dark color scheme based on the Monokai theme from notepad++. Which I use for my not mxs related coding.

Hope this helps some people. Oh and as a positive side effect the particle flow editor is much better readable!

Cheers,
-Johan

*some funky linebeaking going on, manually check the lines and discard the extra whitespaces or use the attached clean txt file.

erb
12-23-2009, 07:49 PM
Thanks for sharing!

galagast
12-24-2009, 05:43 AM
Just in case anyone missed this tip from the helpfile.

You can use a vertical line character '|' to position the caret after expanding the abbreviation.

here's a very simple example where I found this quite useful:
tc=try(|)catch()
The caret/cursor will be conveniently placed inside the TRY block.

JHN
12-24-2009, 08:09 AM
tc=try(|)catch()
The caret/cursor will be conveniently placed inside the TRY block.

That's a great tip!! Thanks!
-Johan

epic1511
06-23-2010, 12:30 PM
it seems all of u guys know what maxscript is all about!

wish i could be like one of u someday...Amen

iam an undergraduate student and i have my project involving maxscript

i tried fulfilling some tasks in maxscript ,some were made well and many were only to waste my time...my project needs simulation of "people walking in street randomly"

i tried watching some tutorials to handle this simulation using "crowd-bipes"
however..i didnt get many tips besides not finding what i want exactly

i have tried to handle crowd of delegates before, and i thought that "crowd of delegates" script may only need some changes to fit crowd of bipes ,but i couldn't figure out these changes!

i only started learning maxscript since 2 months....so do u think u can help me?

this is the script of "delegates following some leader"..hope u can turn it to "bipes walking randomly".

animationRange = interval animationRange.start 150f
(
local switcher = off
local theRolloutFloater
local Test
local Custom_Leader
local TheFrame
local TheSurface
local Arr_Obstacles
local Arr_Delegates
local TheTarget
local C
local Leader
local Sur
local Distribution_Object
local Del
local Obstacles
local Simulation
local Leader_Proxy
local Environment_Setup
local assin_01
local assin_02
local assin_03
local team_01
----Functions -----
Fn TicksToFrames TheFrame =
(
--This Function Changes Ticks to frames NO matter what Frame rate is Pal , NTSC , Film ....etc
(TheFrame as integer/TicksPerFrame)
)


/*
this function creates the Crowd helper , the behaviors and the teams
*/
Fn MakeTheCrowd Num_Of_Delegates Frames =
(
Try( Delete $Delegate* ; Delete $First_Crowd* ; )Catch()

delegate width:6 depth:9 height:6 xyconstraint:false WireColor:Red
-- Constructing the Crowd Helper !
C = crowd name:"First_Crowd" pos:[320,150,0] IconSize:50 SolveEnd:Frames
C.scatter.positionspace = 3
C.scatter.positionobject = $TheSphere
C.scatter.cloneobject = $delegate01
C.scatter.numclones = Num_Of_Delegates - 1
C.scatter.clonetype=0
crowds.genclones C
crowds.genlocations C
Arr_Delegates = $Delegate* as array
C.deleteKeys = true

--surface follow behavior
TheSurfaceFollow_Behavior = Surface_Follow_Behavior name:"SurfaceFollow"
Append TheSurfaceFollow_Behavior.Surfaces TheSurface
append C.Behaviors TheSurfaceFollow_Behavior
--seek behavior
TheSeekTarget_Behavior = Seek_Behavior name:"Seek_Target"
Append TheSeekTarget_Behavior.targets TheTarget
append C.Behaviors TheSeekTarget_Behavior
--avoid behavior
TheAvoid_Behavior = Avoid_Behavior name:"Avoid_Delegates&Obstacles"
for i in Arr_Delegates do (Append TheAvoid_Behavior.Obstacles i)
if Arr_Obstacles != undefined do for i in Arr_Obstacles do (Append TheAvoid_Behavior.Obstacles i)
TheAvoid_Behavior.HardRadius = 0.4
TheAvoid_Behavior.LookAhead = 40
append C.behaviors TheAvoid_Behavior

team_01 =CrowdTeam()
team_01.name = "All_Delegate"
team_01.members = Arr_Delegates
append C.teams team_01

assin_01 = crowdassignment team:team_01 behavior:TheSeekTarget_Behavior active:true
append C.assignments assin_01
assin_02 = crowdassignment team:team_01 behavior:TheSurfaceFollow_Behavior active:true
append C.assignments assin_02
assin_03 = crowdassignment team:team_01 behavior:TheAvoid_Behavior active:true
append C.assignments assin_03
)
/*
--this function creates a plane adds a noise and bend modifier and collapse the stack
--then it selects an edge and extract a path
--a leader is generated and assigned the path as path constraint
--then it generates and aligns obstacles according to the number of obstacles
--if an obstacle is not aligned properly by intersectray it gets deleted
*/

fn autoEnvironment numobstacles theColor switcher = (
try(
SuspendEditing()
resetMaxFile #noPrompt -- due to scope limitation a max reset was decided !
ResumeEditing()

)catch()
P = converttopoly(Plane width:250 length:500 lengthsegs:40 widthsegs:40)
N = NoiseModifier()
N.Fractal = true
addModifier P N
N.Strength.z = 50
B = Bend()
addmodifier P B
B.angle = -180 ; B.BendAxis = 0
B2 = Bend Angle: -90 BendAxis:1 ; addmodifier P B2
collapsestack p
polyop.setEdgeSelection P 160
P.EditablePoly.SelectEdgeLoop ()
P.EditablePoly.createShape "thePath" on P
if switcher == off then S = sphere radius:10 wirecolor:theColor else s = Box length:10 width:10 height:10 wirecolor:theColor
pc = path_constraint()
S.pos.Controller = pc
pc.path = $thePath
for i = 1 to numobstacles do (
theBox = box length:(random 5 10) width:(random 5 10) height:(random 5 10) Name:(uniquename "Obstacle_01"); CenterPivot theBox
theBox.wirecolor = (random white gray)
theBox.pos = [(random P.min.x P.max.x) , (random P.min.y P.max.y) , (random P.min.z P.max.z)]
in coordsys local (theBox.rotation.x = random 1 180 ; theBox.rotation.y = random 1 180; theBox.rotation.z = random 1 180)
theRay = ray theBox.pivot [theBox.pos.X,theBox.pos.Y,-50000]
theintersection = intersectray P theRay ; print theintersection
if theintersection != undefined then theBox.pos = theintersection.pos else delete theBox
redrawviews()
)

)


-- UI Configurateion
--these are set of rollouts and their event handlers made separatly and then added to a rollout floater
--if the user chooses to AutoEnvironment an additional rollout is created to give the options

--simple rollout to choose auto or manual creation of the environment
rollout Mode "Environment Mode"
(
Group "Mode"
(
radioButtons rdo1 "" labels:#("Manual","Auto_Environment ") default:1 columns:1 Align:#Center
)

on rdo1 changed item do
(
if item == 1 then
(
for i in theRolloutFloater.Rollouts do if i != Mode do removerollout i theRolloutFloater
addrollout Leader theRolloutFloater
addrollout Sur theRolloutFloater
addrollout Distribution_Object theRolloutFloater
addrollout Del theRolloutFloater
addrollout Obstacles theRolloutFloater
addrollout Simulation theRolloutFloater
)
else
(
for i in theRolloutFloater.Rollouts do if i != Mode do removerollout i theRolloutFloater
--addrollout Leader_Proxy theRolloutFloater
addrollout Environment_Setup theRolloutFloater
addrollout Leader theRolloutFloater
addrollout Sur theRolloutFloater
addrollout Distribution_Object theRolloutFloater
addrollout Del theRolloutFloater
addrollout Obstacles theRolloutFloater
addrollout Simulation theRolloutFloater
)
)
)
--environment options
rollout Environment_Setup "Environment_Setup"
(
Group "Obstacles"

(
Spinner No_Obstacles "Up To" type:#integer range:[1,1000000,40] Align:#Center
)

Group "Leader"
(
dropDownList ddl1 width:100 height:40 items:#("Sphere", "Box") align:#left across:2
colorPicker cp1 "" width:20 height:20 color:(color 255 0 0) align:#right across:2
)
Button Btn_Env "Generate Envoronment" ali:#center

on ddl1 selected item do
(

if item == 2 then switcher = on else switcher = off
)
on Btn_Env pressed do autoEnvironment NO_Obstacles.value cp1.color switcher

)
-- the leader rollout .. this rollout provides a button to choose the leader
rollout Leader "Leader"
(
Group "Leader"
(
PickButton PB_Leader "Pick The Leader !" Align:#Center AutoDisplay:true
)

on PB_Leader Picked obj do
(
if obj != undefined do TheTarget = obj
)

)

--the surface rollout .. this rollout provides a button to choose the Surface
rollout Sur "Surface"
(
Group "Surface"
(
Pickbutton PB_Surface "Pick The Surface !" Align:#Center AutoDisplay:true
)

on PB_Surface Picked obj do
(
if obj != undefined do TheSurface = obj
)
)
--distribution rollout ... proper values for autoEnvironment is x = - 130 and y = -240
rollout Distribution_Object "Distribution Object"
(
Group "Distribution Object"
(
Button Btn_Help "?" Across:2 align:#left
Button Btn_SphereDistribution "Create The Object" Across:2 align:#Right
Spinner Spin_Radius "Radius" type:#Float range:[0.001,1000000,40] Align:#Center enabled:false
Spinner Spin_Xpos "Position X" type:#Float range:[-1000000,1000000,0] Align:#Center enabled:false
Spinner Spin_Ypos "Position Y" type:#Float range:[-1000000,1000000,0] Align:#Center enabled:false
Spinner Spin_Zpos "Position Z" type:#Float range:[-1000000,1000000,0] Align:#Center enabled:false
)

on Btn_Help pressed do
(
MessageBox "This is a Distribution Sphere meant to Distribute the Delegates initially \n ControlThe Radius and Position for best Sim Environment "
)
on Btn_SphereDistribution pressed do
(
Try(Delete $TheSphere*)Catch()
Sphere name:"TheSphere" pos:[0,0,0] segments:40 radius:40
Spin_Radius.enabled = true
Spin_Xpos.enabled = true
Spin_Ypos.enabled = true
Spin_Zpos.enabled = true
)

on Spin_Radius changed val do ($TheSphere.Radius = Spin_Radius.Value)
on Spin_Xpos Changed val do ($TheSphere.Position.X = Spin_Xpos.Value)
on Spin_Ypos Changed val do ($TheSphere.Position.Y = Spin_Ypos.Value)
on Spin_Zpos Changed val do ($TheSphere.Position.Z = Spin_Zpos.Value)

)


--number of delegates to follow the leader
rollout Del "Delegates"
(
Group "Delegates"
(
Spinner Spin_NumDelegates "No. Delegates" type:#integer range:[1,50000000,10] align:#center
)
)
--this rollout provides a method to choose the obstacles
rollout Obstacles "Obstacles"
(
Group "Obstacles"
(
Button Btn_PickObstacles ">> Select Obstacles <<" width:(Obstacles.width - 20) Align:#Center
Label lab_01 "No. Obstacles = 0"
)

on Btn_PickObstacles Pressed do
(
max tool hlist
if (Selection.Count == 0 ) then (lab_01.text = "No Obstacles Assigned ")
else (
Arr_Obstacles = Selection as array
lab_01.text = "No. Obstacles = " + Selection.count as string
)
)
on Btn_Help pressed do
(
MessageBox "This is a Distribution Sphere meant to Distribute the Delegates initially \n ControlThe Radius and Position for best Sim Environment "
)
)
--Simulation rollout ... self explanatory
rollout Simulation "Simulation"
(
Group "Simulation"
(
Spinner Spin_Frames "Frames" type:#integer range:[1,TicksToFrames AnimationRange.End,TicksToFrames AnimationRange.End] align:#center
Button Btn_Solve "Solve" Width:(Simulation.width - 40) Height:30
)

on Btn_Solve pressed do
(
if (TheSurface !=undefined and TheTarget !=undefined and $TheSphere != undefinde) Then
(
MakeTheCrowd Del.Spin_NumDelegates.Value Spin_Frames.Value
Crowds.Solve C
)
else (MessageBox "Please Fill The Parameters First ")
)
)

theRolloutFloater= newrolloutfloater "Crowd_Solver" 180 200
addrollout Mode theRolloutFloater
addrollout Leader theRolloutFloater
addrollout Sur theRolloutFloater
addrollout Distribution_Object theRolloutFloater
addrollout Del theRolloutFloater
addrollout Obstacles theRolloutFloater
addrollout Simulation theRolloutFloater

)

JHN
06-23-2010, 12:46 PM
epic1511, I think you are better of starting a new thread and cleaning this post, it's off topic for this thread, also have a look at the code # button in the editor it does a better job on the formatting and readability.

But maxscript is really cool, and like with anything if you do it a lot, you'll get good at it, or at least proficient ;)
Cheers,
-Johan

epic1511
06-23-2010, 01:20 PM
thanks johan

i will consider # button next time :lightbulb

but do u think u can help me with my script...i really need it and dont know what to do??

i have spent more than 6 days trying to figure out something but its all useless!

c# is much much better....however my constructor insists on learning maxscript

MattRennie
03-16-2011, 06:23 PM
I know this can be done but I just can't remember how - anyone know how I can change the colour of my current set of ( and ) - at present the opposite one to my cursor position goes a slightly lighter blue but I want to make this a bit more obvious...

hblan
04-02-2011, 02:00 PM
hi JHN:
many thanks for ur maxscript.api (http://scripts.subd.nl/?f=maxscript.api) file .
Im using Vim writing maxscript . this api file is very clean , and I just rename it to maxscript.dict . running very good in vim .

coz ur thread about " maxscript autocomplete " has been closed . so I come here to say :
ur maxscript.api file is really a greatjob .:thumbsup:

many thanks !

CriticalErr0r
07-09-2011, 07:14 PM
Hello, well first of all I want say thanks for this good tutorial, and well maybe you can help me with 1 script, because I'm new and can't make it work, when try import a file into max it say me that.

http://forum.xentax.com/download/file.php?id=4337

if (heapSize < 20000000) then
heapSize = 200000000 -- allow ~ 40 MB instead of just 7.5 MB. Prevents "Runtime Error: Out of scripter memory"

fname = GetOpenFileName caption:"Open 7 Souls Model File" types:"7 Souls Model File(*.msh)|*.msh"
f = fopen fname "rb" --open file in read only format
base = getFilenamePath fname
basefile = getFilenameFile fname -- returns: "myImage.jpg"
basefile = substring basefile 3 (basefile.count - 2)
ss = substring base 1 (base.count - 5) -- returns "rof"
print basefile
print ss
DiffuseTex = (ss + "texture\diffuse\4" + basefile + ".dds")

print DiffuseTex
fn ReadFixedString bstream fixedLen =
(
local str = ""
for i = 1 to fixedLen do
(
str += bit.intAsChar (ReadByte bstream #unsigned)
)
str
)

struct weight_data
(
boneids,weights
)

Vert_array = #()
Normal_array = #()
UV_array = #()
Face_Array = #()
Weight_array = #()
VertID_array = #()

idstring2 = ReadFixedString f 4
if idstring2 != "MESH" do (
BoneFile = readlong f
Skelleton = (ss + "bind\g" + (BoneFile as string) + ".bnd")
print Skelleton
print ("BoneFile" + "_" + (BoneFile as string))
Mesh_Name_Size = readlong f
Mesh_Name = ReadFixedString f Mesh_Name_Size
vertcount = readlong f
facecount = readlong f
weightcount = readlong f
weightcount2 = readlong f
for i = 1 to vertcount do (
vx = readfloat f --read xyz coordinates
vy = readfloat f
vz = readfloat f
nx = readfloat f
ny = readfloat f
nz = readfloat f
tu = readfloat f
tv = readfloat f * -1
append Vert_array [vx,vy,vz] --save verts to Vert_array
append UV_array [tu,tv,0]
append Normal_array [nx,ny,nz]
)
facedirection = 1
for i = 1 to facecount do (
f1 = readlong f + 1
f2 = readlong f + 1
f3 = readlong f + 1
append Face_array [f1,f2,f3]
)
for i = 1 to weightcount do (
boneids = ((readlong f) + 1)
VertID = ((readlong f) + 1)
weights = readfloat f
v2 = readlong f
w2 = readfloat f
v3 = readlong f
w3 = readfloat f
v4 = readlong f
w4 = readfloat f
append Weight_array (weight_data boneids:boneids weights:weights)
append VertID_array VertID
)
for i = 1 to weightcount2 do (
bone1 = readlong f
VertID = ((readlong f) + 1)
weight1 = readfloat f
w = (weight_data boneids:#() weights:#())
w1 = weight1 as float
append w.boneids (bone1+1)
append w.weights (w1)
v2 = readlong f
w2 = readfloat f
v3 = readlong f
w3 = readfloat f
v4 = readlong f
w4 = readfloat f
append Weight_array w
append VertID_array VertID
)
print (ftell f)
msh = mesh vertices:Vert_array faces:Face_array --build mesh
msh.numTVerts = UV_array.count
buildTVFaces msh
meditMaterials[1] = Standardmaterial ()
msh.material = meditMaterials[1]
meditMaterials[1].diffuseMap = Bitmaptexture fileName:DiffuseTex
meditMaterials[1].opacityMap = Bitmaptexture fileName:DiffuseTex
meditMaterials[1].opacityMap.monoOutput = 1
msh.name = Mesh_Name
for j = 1 to UV_array.count do setTVert msh j UV_array[j]
for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
for j = 1 to Normal_array.count do setNormal msh j Normal_array[j]
)
print (ftell f)
usedbones_array = #()
if idstring2 == "MESH" do (
mcount = readlong f
mid = readlong f
BoneFile = readlong f
Skelleton = (ss + "bind\g" + (BoneFile as string) + ".bnd")
print Skelleton
print ("BoneFile" + "_" + (BoneFile as string))
Mesh_Name_Size = readlong f
Mesh_Name = ReadFixedString f Mesh_Name_Size
vertcount = readlong f
facecount = readlong f
for i = 1 to vertcount do (

vx = readfloat f --read xyz coordinates
vy = readfloat f
vz = readfloat f
nx = readfloat f
ny = readfloat f
nz = readfloat f
tu = readfloat f
tv = readfloat f * -1
if mcount == 2 Do (
fseek f 0x10#seek_cur
)
Bone1 = readbyte f#unsigned
Bone2 = readbyte f#unsigned
Bone3 = readbyte f#unsigned
Bone4 = readbyte f#unsigned
weight1 = readfloat f
weight2 = readfloat f
weight3 = readfloat f
weight4 = readfloat f

w = (weight_data boneids:#() weights:#())
maxweight = 0
if(Bone1 != 0) then
maxweight = maxweight + weight1
if(Bone2 != 0) then
maxweight = maxweight + weight2
if(Bone3 != 0) then
maxweight = maxweight + weight3
if(Bone4 != 0) then
maxweight = maxweight + weight4

if(maxweight != 0) then (
if(weight1 != 0) then (
w1 = weight1 as float
append w.boneids (bone1 + 1)
append w.weights w1
)
if(weight1 != 0) then (
w2 = weight2 as float
append w.boneids (bone2 + 1)
append w.weights w2
)
if(weight1 != 0) then (
w3 = weight3 as float
append w.boneids (bone3 + 1)
append w.weights w3
)
if(weight1 != 0) then (
w4 = weight4 as float
append w.boneids (bone4 + 1)
append w.weights w4
)
)
append Weight_array w
append Vert_array [vx,vy,vz] --save verts to Vert_array
append UV_array [tu,tv,0]
append Normal_array [nx,ny,nz]
)
if mcount == 2 Do (
usedbones = readbyte f#unsigned
for a = 1 to usedbones do (
bid = readbyte f#unsigned + 1
append usedbones_array bid
)
)
facedirection = 1
if mcount == 2 Do (
for i = 1 to facecount do (
f1 = readshort f + 1
f2 = readshort f + 1
f3 = readshort f + 1
append Face_array [f1,f2,f3]
)
)
if mcount == 1 Do (
for i = 1 to facecount do (
f1 = readlong f + 1
f2 = readlong f + 1
f3 = readlong f + 1
append Face_array [f1,f2,f3]
)
)
print (ftell f)
msh = mesh vertices:Vert_array faces:Face_array --build mesh
msh.numTVerts = UV_array.count
buildTVFaces msh
meditMaterials[1] = Standardmaterial ()
msh.material = meditMaterials[1]
meditMaterials[1].diffuseMap = Bitmaptexture fileName:DiffuseTex
meditMaterials[1].opacityMap = Bitmaptexture fileName:DiffuseTex
meditMaterials[1].opacityMap.monoOutput = 1
msh.name = Mesh_Name
for j = 1 to UV_array.count do setTVert msh j UV_array[j]
for j = 1 to Face_array.count do setTVFace msh j Face_array[j]
for j = 1 to Normal_array.count do setNormal msh j Normal_array[j]
)
actionMan.executeAction 0 "63508"

fclose f
f = fopen Skelleton "rb"
idstring = ReadFixedString f 4
BNArr = #()
if idstring != "BIND" Do (
nsize = readlong f
skelname = ReadFixedString f nsize
bonecount = readlong f
for a = 1 to bonecount Do (
boneid = readlong f + 1
boneparent = readlong f + 1
f1 = readfloat f
f2 = readfloat f
f3 = readfloat f
f4 = readfloat f
f5 = readfloat f
f6 = readfloat f
f7 = readfloat f
tfm = (quat f4 f5 f6 (f7 * -1)) as matrix3
tfm.row4 = [f1,f2,f3]
if isvalidnode (getNodeByName (a as string)) != true then (
if (boneparent != boneid) do (
tfm = tfm * BNArr[boneparent].objecttransform
)
newBone = bonesys.createbone \
tfm.row4 \
(tfm.row4 + 0.01 * (normalize tfm.row1)) \
(normalize tfm.row3)
newBone.name = (a as string)
newBone.width = 0.01
newBone.height = 0.01
newBone.transform = tfm
newBone.setBoneEnable false 0
newBone.wirecolor = yellow
newbone.showlinks = true
newBone.pos.controller = TCB_position ()
newBone.rotation.controller = TCB_rotation ()
if (boneparent != 0) then
newBone.parent = BNArr[boneparent]
append BNArr newBone
)
)
)

if idstring == "BIND" Do (
fseek f 0x8#seek_cur
nsize = readlong f
skelname = ReadFixedString f nsize
bcount1 = readbyte f#unsigned
bcount2 = readbyte f#unsigned
bonecount = (bcount1 + bcount2)
for a = 1 to bonecount Do (
boneid = readlong f + 1
boneparent = readlong f + 1
f1 = readfloat f
f2 = readfloat f
f3 = readfloat f
f4 = readfloat f
f5 = readfloat f
f6 = readfloat f
f7 = readfloat f
null = readbyte f#unsigned
tfm = (quat f4 f5 f6 (f7 * -1)) as matrix3
tfm.row4 = [f1,f2,f3]
if isvalidnode (getNodeByName (a as string)) != true then (
if (boneparent != boneid) do (
tfm = tfm * BNArr[boneparent].objecttransform
)
newBone = bonesys.createbone \
tfm.row4 \
(tfm.row4 + 0.01 * (normalize tfm.row1)) \
(normalize tfm.row3)
newBone.name = (a as string)
newBone.width = 0.01
newBone.height = 0.01
newBone.transform = tfm
newBone.setBoneEnable false 0
newBone.wirecolor = yellow
newbone.showlinks = true
newBone.pos.controller = TCB_position ()
newBone.rotation.controller = TCB_rotation ()
if (boneparent != 0) then
newBone.parent = BNArr[boneparent]
append BNArr newBone
)
)
)
max modify mode
print idstring
if idstring2 != "MESH" do (

select msh
skinMod = skin ()
addModifier msh skinMod
for i = 1 to BNArr.count do
(
maxbone = getnodebyname BNArr[i].name
if i != BNArr.count then
skinOps.addBone skinMod maxbone 0
else
skinOps.addBone skinMod maxbone 1
)
modPanel.setCurrentObject skinMod
for i = 1 to Weight_array.count do
(
skinOps.SetVertexWeights skinMod VertID_array[i] Weight_array[i].boneids Weight_array[i].weights
)
)

if idstring2 == "MESH" do (
if mcount == 2 Do (
BNArr = #()
for a = 1 to usedbones_array.count do (
append BNArr (getnodebyname (usedbones_array[a] as string))
)
)
select msh
skinMod = skin ()
addModifier msh skinMod
for i = 1 to BNArr.count do
(
maxbone = getnodebyname BNArr[i].name
if i != BNArr.count then
skinOps.addBone skinMod maxbone 0
else
skinOps.addBone skinMod maxbone 1
)
modPanel.setCurrentObject skinMod
for i = 1 to Weight_array.count do
(
w = Weight_array[i]
bi = #()
wv = #()
for j = 1 to w.boneids.count do
(
boneid = w.boneids[j]
weight = w.weights[j]
append bi boneid
append wv weight
)
skinOps.ReplaceVertexWeights skinMod i bi wv
)
)

max create mode
max zoomext sel all
fclose f

PePeTD
08-16-2011, 08:06 PM
Can you be a little more specific on the issue ?

Andreseloy
09-16-2011, 11:47 PM
1.-first at all, big thanks for the tip_big_tools.
i want to know if possible to make an adittion to the Editor User.Properties so i can change in real time the colors...using the color palette.
2.-I dont know how to change in that script the color selection, for me is hard to see the diference (selec/non select).
the image attached help to explain what i need

Thanks in advance

hblan
04-20-2012, 01:50 AM
Im using vim for a long time , as the editor of maxscript . I write a listener script , let it start when max start up . it is a timer , check a file when tick tick , then run the edited script found in a specific folder .

rollout debugTool ""
(
checkbutton switchClock "debug" checked:true
timer checkclock "checkclock" interval:1000 active:true
on switchClock changed val do
(
if switchClock.checked then
(
checkClock.active = true
)else
(
checkClock.active = false
)
)
on checkclock tick do
(
-- read file in C folder .
if ( doesfileexist "c:\\src.ms" ) then
(
-- delete old exe file .
deletefile "c:\\debug.ms"
-- copy file .
copyfile "c:\\src.ms" "c:\\debug.ms"
-- delete old src file .
deletefile "c:\\src.ms"
-- run file .
try ( filein "c:\\debug.ms" ) catch ( print " error in debug " )
)
)


)createdialog debugTool 40 30 0 0




in Vim , edit the _vimrc file , add a line :

:imap <esc>:w<cr>:w! c\\src.ms<cr>



that is : edit the codes in Vim , when press F5 , vim will write the buffer to file name : c:\\src.ms . coz the max started , and my script running , when tick , it will get the file , src.ms , then copy it to debug.ms , delete src.ms , run debug.ms . that is my way .



the connection of vim and 3ds max need a listener , so , let max script do it .



we can enjoy powerful Vim , superTab , nerdTree , fast dictionary for autocomplete , map keys , abbreviate self define ....

the dict file can be convert from maxscript.api file which fit for sciTE .

hblan
04-20-2012, 01:57 AM
repeated .

easyfrog
05-16-2012, 04:37 AM
Project panel in Maxscript Editor?
Maxscript Editor is use SciTE. So can realize a project window management dock left in it ? that will be prety cool! and useful.

denisT
05-16-2012, 05:23 AM
Project panel in Maxscript Editor?
Maxscript Editor is use SciTE. So can realize a project window management dock left in it ? that will be prety cool! and useful.

i showed on this forum how to make any dialog/window dockable...

Track
11-19-2013, 10:21 PM
Is it possible to highlight all similar to selected word in the maxscript editor?
selection blabla bla same word: selection
The option highlight.current.word=1 from http://www.scintilla.org/SciTEDoc.html not work for me.