-
Is there documentation online somewhere for ScriptContext? I have looked in the scriptcontext.py file on my machine at C:\Users<user>\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib and that has very limited information. It hardly lists anything.
-
What’s the difference between sc.doc.Objects and sc.doc.ActiveDoc.Objects? The same goes for other properties and methods like Open(), BeginUndoRecord(), etc. If they are the same then what’s the purpose in having an ActiveDoc class? There must be a difference between the two. I have seen many scripts reference sc.doc.Objects and not sc.doc.ActiveDoc.Objects.
Hi @Mike24,
You’re correct, there isn’t much in scriptcontext.py.
The primary uses are to:
- Provide access to the document that was active when the script is executed.
- Provide access a global dictionary that can be used to store values between script executions.
Also, ActiveDoc
is not reliable, as Rhino for Mac can have multiple docs open and there can be a pseudo document used in the context of Grasshopper. Using scriptcontext.doc
is best as it lets you use the appropriate RhinoDoc
in the context of the script being run.
– Dale