PDA

View Full Version : Maxscript local Help ?


Zbuffer
10-11-2011, 09:14 AM
Hi all,

How can I get Maxscript to use the local version instead of the online help?
I have downloaded the Maxscript htlm (http://images.autodesk.com/adsk/files/maxscript-doc-2012.zip) help, but can't find any way to use from within max.
I managed to get the general help to use the local version (preferences), but can't get it to work for the Maxscript help.

Any clues ?

Regards,
Zbuffer

Nysuatro
10-11-2011, 10:06 AM
What version are you using?
Normally there is a helpfile in you programs folder

"C:\Program Files (x86)\Autodesk\3ds Max 2010\help\maxscript.chm"

If you just make a shortcut to that file on your desktop you do not have to connect anymore to the internet.
I did not knew max used the online version .. Is that since 2012 ?

spacefrog
10-11-2011, 10:09 AM
only way is to code a small macroscript and hook it to your preferred shortcut/menu.
something like


shelllaunch "D:\\3DSMax2012\\Help\\Maxscript\\index.html" ""


should do it...
Just change the path to your config

lucpet
10-11-2011, 12:17 PM
Hi all,

How can I get Maxscript to use the local version instead of the online help?
I have downloaded the Maxscript htlm (http://images.autodesk.com/adsk/files/maxscript-doc-2012.zip) help, but can't find any way to use from within max.
I managed to get the general help to use the local version (preferences), but can't get it to work for the Maxscript help.

Any clues ?

Regards,
Zbuffer
From what I could work out you can have one or the other, but not both and the other ideas posted here may be your only choice.

Zbuffer
10-15-2011, 02:35 PM
Late reply...

I am using max 2012, so no .chm, only online help.
using 'customize/preferences/help' i can point to a local folder, but there is no setings for the maxScript help :(
shellLaunch can launch index but how to get the current word in Maxscript editor to be passed to the index, replacing the original F1 help that points to the online help ?

S-ed
01-28-2012, 07:58 PM
Maxscript 2012 help launcher (http://www.scriptspot.com/3ds-max/scripts/maxscript-2012-help-launcher)
But F1 still not working...

Zbuffer
01-29-2012, 02:42 PM
Hi,
I have something... but it does not work and I need Help:

Thanks to the one and only DenisT, and his dotnet Magic,
I can retreive the word at the carret position in the editor.
But I can't get the parameters to work with "ShellLaunch"
it only opens the index.html file (and NOT the '?query=MySearch'
Any ideas ?
here is the script so far:
(click a word in MXS editor and evaluate)
/*
MaxScript Local Help
*/

(
global Win32Assembly
local MXS_HELP_DIR="D:/3D/3dsmax2012/maxscript-doc-2012/"

fn CreateWin32Assembly forceRecompile:on =
(
if forceRecompile or not iskindof ::Win32Assembly dotnetobject or (::Win32Assembly.GetType()).name != "Assembly" do
(
source = "using System;\n"
source += "using System.Runtime.InteropServices;\n"
source += "using System.Text;\n"
source += "class Win32\n"
source += "{\n"
source += " [DllImport(\"user32\", CharSet = CharSet.Auto, SetLastError = true)]\n"
source += " public static extern Int32 SetFocus(Int32 hWnd);\n"
source += " [DllImport(\"user32\", CharSet = CharSet.Auto, SetLastError = true)]\n"
source += " internal static extern int GetWindowTextLength(Int32 hWnd);\n"
source += " [DllImport(\"user32\", CharSet = CharSet.Auto, SetLastError = true)]\n"
source += " internal static extern int GetWindowText(Int32 hWnd, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpString, int nMaxCount);\n"
source += " public static string GetWindowText(Int32 hWnd)\n"
source += " {\n"
source += " int length = GetWindowTextLength(hWnd);\n"
source += " StringBuilder sb = new StringBuilder(length + 1);\n"
source += " GetWindowText(hWnd, sb, sb.Capacity);\n"
source += " return sb.ToString();\n"
source += " }\n"
source += "}\n"

csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"

compilerParams.ReferencedAssemblies.Add "System.dll"
compilerParams.ReferencedAssemblies.Add "System.Drawing.dll"

compilerParams.GenerateInMemory = true
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)

Win32Assembly = compilerResults.CompiledAssembly
Win32Assembly.CreateInstance "Win32"
)
)
global Win32 = CreateWin32Assembly()

fn isStopChar s =
(
local valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"
local i = findstring valid s
if i == undefined then true else false
)

fn GetWord txt pos =
(
local start = for i = pos to 1 by -1 do if (isStopChar txt[i]) do exit with (i+1)
local end = for i = pos to txt.count do if (isStopChar txt[i]) do exit with i
trimright(substring txt start (end-start))
)

fn LaunchHelp str =
(
url="file:///"+MXS_HELP_DIR+"index.html?query=" + str
format "URL:%\n" url
ShellLaunch url ""
)

fn GetWordatCarretPos =
(
fn _mxs_Textbox =
(
tb = for c in (windows.getchildrenhwnd 0) where c[4] == "MXS_SciTEWindow" do exit with
(
for t in (windows.getchildrenhwnd c[1]) where t[4] == "MXS_Scintilla" do exit with t[1]
)
if tb != ok then tb else undefined
)

val=0
EM_GETSEL = 0x00B0
tb = _mxs_Textbox()
tx = Win32.GetWindowText tb
CarretPos = (windows.sendmessage tb EM_GETSEL val val)/65535
--print CarretPos
--Win32.SetFocus tb
GetWord tx CarretPos
)
LaunchHelp (GetWordatCarretPos())
)

Zbuffer
01-29-2012, 09:57 PM
OK,
I have this kind of working...
but I cannot assign a shortcut that will trigger it while in the MXS editor :(
Otherwise if you comment out the macroscript definition, you can test it on the script itself
/*
MXS_Help.ms
MaxScript Local Help Launcher
dotnet User32 magic vastely inspired by DenisT
*/

macroscript MXS_HELP
category:"MAX Script"
toolTip:"Context Help"
(

on execute do
(
fn CreateWin32Assembly forceRecompile:off =
(
if forceRecompile or not iskindof ::Win32Assembly dotnetobject or (::Win32Assembly.GetType()).name != "Assembly" do
(
source = "using System;\n"
source += "using System.Runtime.InteropServices;\n"
source += "using System.Text;\n"
source += "class Win32\n"
source += "{\n"
source += " [DllImport(\"user32\", CharSet = CharSet.Auto, SetLastError = true)]\n"
source += " public static extern Int32 SetFocus(Int32 hWnd);\n"
source += " [DllImport(\"user32\", CharSet = CharSet.Auto, SetLastError = true)]\n"
source += " internal static extern int GetWindowTextLength(Int32 hWnd);\n"
source += " [DllImport(\"user32\", CharSet = CharSet.Auto, SetLastError = true)]\n"
source += " internal static extern int GetWindowText(Int32 hWnd, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpString, int nMaxCount);\n"
source += " public static string GetWindowText(Int32 hWnd)\n"
source += " {\n"
source += " int length = GetWindowTextLength(hWnd);\n"
source += " StringBuilder sb = new StringBuilder(length + 1);\n"
source += " GetWindowText(hWnd, sb, sb.Capacity);\n"
source += " return sb.ToString();\n"
source += " }\n"
source += "}\n"

csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"

compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.ReferencedAssemblies.Add "System.dll"
compilerParams.ReferencedAssemblies.Add "System.Drawing.dll"
compilerParams.GenerateInMemory = true

compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)

Win32Assembly = compilerResults.CompiledAssembly
Win32Assembly.CreateInstance "Win32"
)
)

global Win32 = CreateWin32Assembly()

/* Launches IE
*/
fn LaunchHelp str =
(
MXS_HELP_DIR="D:/3D/3ds Max 2012/help/maxscript-doc-2012/"
IE32 = "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe"
IE = "C:\\Program Files\\Internet Explorer\\iexplore.exe"
url="file:///"+MXS_HELP_DIR+"index.html"
if str.count>0 do url += ("?query=" + str)
--ShellLaunch url "" -- :( :( :( DOES NOT PLAY WITH FIREFOX...
-- This Works wIth x64 Windows
if doesFileExist IE32 then ShellLaunch IE32 url
else if doesFileExist IE then ShellLaunch IE url
else ShellLaunch url ""
)

fn GetWordatCarretPos =
(
/* Retreives a complete Word (made of valid chars) at a given position in a string
*/
fn GetWord str pos =
(
fn isStopChar s =
(
local valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789"
local i = findstring valid s
if i == undefined or i == 0 then true else false
)

local start=pos, end=pos, res=""
start = if isStopChar str[pos] then (pos+1)
else if isStopChar str[pos-1] then pos else (for i = pos to 1 by -1 do if isStopChar str[i] do exit with (i+1))
end = if isStopChar str[pos+1] then (pos+1) else (for i = (pos+1) to str.count do if isStopChar str[i] do exit with (i))
res = substring str start (end-start)
res
)

fn _mxs_Textbox =
(
tb = for c in (windows.getchildrenhwnd 0) where c[4] == "MXS_SciTEWindow" do exit with
(
for t in (windows.getchildrenhwnd c[1]) where t[4] == "MXS_Scintilla" do exit with t[1]
)
if tb != ok then tb else undefined
)

EM_GETSEL = 0x00B0
tb = _mxs_Textbox()
tx = Win32.GetWindowText tb
Win32.SetFocus tb
CarretPos = (windows.sendmessage tb EM_GETSEL 0 0)/65535
GetWord tx CarretPos
)
LaunchHelp (GetWordatCarretPos())
)
)

S-ed
01-31-2012, 02:47 PM
My method uses the default methods available in the maxscript editor. You can add your own keyboard shortcuts for some actions in the scintilla editor. One of these actions opens a predefined file: the scintilla helpfile.
http://www.scriptspot.com/3ds-max/tutorials/maxscript-help-for-3dsmax-2012


There are not mentioned, but in
Tools -> Open Global Options File
You can find
# SciTE help
command.scite.help="file://$(SciteDefaultHome)\Help\SciTEDoc.html"
command.scite.help.subsystem=2

S-ed
01-31-2012, 05:39 PM
Put this code to Tools -> Open User Options File
command.name.12.*=Find in Help
command.12.*=C:\-blah-blah-blah-\opera\opera.exe "file://C:\-blah-blah-blah-\3ds Max 2012\Help\maxscript\index.html?query= $(CurrentSelection)"
command.subsystem.12.*=2
command.mode.12.*=savebefore:no
command.shortcut.12.*=Ctrl+F1
You can remove:
command.name.12.*=Find in Help
Replace
C:\-blah-blah-blah-\opera\opera.exe
With any string/browser You wanted.
And
C:\-blah-blah-blah-\3ds Max 2012\Help\maxscript\index.html
To path of Maxscript Help File.

grabjacket
02-01-2012, 06:40 PM
Nice Alex Mak,
this was missing from my solution. The ability to have the help point directly to the item you want help for. I'll update my article to incorporate your solution.
Klaas

S-ed
02-02-2012, 08:44 AM
grabjacket
Thanks to Your info about SciTe.

I'm disappointed about this "decision" to make help online. Legacy .chm was times faster.
Same thing with Adobe.
Seems like Lua disabled in Max's SciTe. =(

Zbuffer
Looks like a lot of work to me.
And most interesting, that maxscript can embed other language, looks fearsome...

Zbuffer
02-02-2012, 09:52 AM
Very interesting,
The drawback with the global Options is that it only takes a selection, that's vcery cool ;)
I like the fact to only click on the word and send this to the help file to get a 'real' context help.
(as it was worling previously with .chm)

S-ed
02-02-2012, 12:15 PM
to only click on the wordoh, sure...
replace
CurrentSelection
with
CurrentWord

grabjacket
02-02-2012, 01:11 PM
Hey Alex,

I've had to edit the lines of code you posted a little bit, but it really works for me: actual contextual, local maxscript help: yay!
# point maxscript to a local helpfile
command.name.12.*=Find in local Help
command.12.*="C:\Program Files (x86)\_web\Firefox\firefox.exe" "file:///C:/Users/klaas/Dropbox/Documentation/maxscript-doc-2012/index.html?query= $(CurrentWord)"
command.subsystem.12.*=0
command.mode.12.*=savebefore:no
command.shortcut.12.*=Ctrl+F1
I had to set the subsystem to 0 to make it work for me.

I've updated my blog-article (http://www.klaasnienhuis.nl/WordPress/2012/02/maxscript-help-for-3dsmax-2012-update/)and added your solution to it.

S-ed
02-02-2012, 03:08 PM
grabjacket
As You like.
I hope to see update on scriptspot too (in pictures X))...

Actually, I'm newbie in maxscript and SciTe. "Googling" + good readme to SciTe.

As help says, after creating command with "number" (12).
It also can be accessed by "id" = 11+"number" (1112)

Like in Your example:
user.shortcuts=\
Ctrl+F1|1112|

The command number can be in the range of 0 to 49. Command numbers 0 to 9 are assigned Ctrl+Number shortcuts.
That's why I've used 12.

JHN
02-03-2012, 09:18 AM
In addition take a look at my post here:
http://forums.cgsociety.org/showpost.php?p=7169617&postcount=12

It adds back the original colors from the old helpfile. You have to add the stylish extension and download the css.

-Johan

SIL3D
11-10-2012, 02:48 PM
OK. Here is another way for local help include CHM.

Its very easy.

1. Download very useful utility from http://www.autohotkey.com/ - it free, open-source macro-creation and automation software utility. And install it. You can use it for another keys remapping in 3ds max window only - such us - left win, TAB, CapsLock etc. Very useful!

2. After run utility and confirm create sample script. Then replace code with this:


#IfWinActive ahk_class 3DSMAX
F1::RUN c:\Program Files\Autodesk\3ds Max 2013\help\Help.chm

#IfWinActive ahk_class #32770
F1::RUN c:\Program Files\Autodesk\3ds Max 2013\help\MaxScript.chm

#IfWinActive ahk_class MXS_SciTEWindow
F1::RUN c:\Program Files\Autodesk\3ds Max 2013\help\MaxScript.chm


And then reload script (ctrl+R) in autohotkey window.

NOTE1: Change your path to CHM help files.
NOTE2: To create CHM - follow instruction from Jonathan de Blok - Maxscript 2013 Help CHM creator (http://www.scriptspot.com/3ds-max/scripts/maxscript-2013-help-chm-creator) and for compiles the standard docs to CHM spacefrog - script (http://www.scriptspot.com/3ds-max/scripts/maxscript-2013-help-chm-creator#comment-17387)

Enjoy!

PS: One thing - not work query for current word. If anybody know about query command line in chm - please give some info.

CGTalk Moderation
11-10-2012, 02:48 PM
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.