Skip to content

Commit ff384cb

Browse files
committed
Minor fixes
- Remove unused string description - Fix typo in scripts\load_python_script_r26.py
1 parent 9e540ea commit ff384cb

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

plugins/py-spherify_modifier_r13/res/strings_us/description/opyspherifydeformer.str

-7
This file was deleted.

scripts/01_foundations/load_python_script_r26.py

+25-19
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Description:
66
- Create a new temporary script.
77
- Load an existing Python file into the Script Manager.
8-
- Retrieve the first script not active in the script manager and make it active.
8+
- Retrieve the first script not active in the Script Manager and make it active.
99
1010
Class/method highlighted:
1111
- c4d.CreateNewPythonScript()
@@ -26,45 +26,49 @@ def CreateNewPythonScript():
2626
# The new script will be set as active automatically.
2727
newScript = c4d.CreateNewPythonScript("", r"print('Sometimes science is more art than science.')")
2828

29-
# ScriptObject being BaseList2D the usual C4DAtom bracket operator can be used to access various properties from it.
29+
# Due to the type ScriptObject being derived from BaseList2D, the bracket operator syntax can be used to access
30+
# the parameters of an instance.
3031
scriptName = newScript[c4d.PYTHONSCRIPT_SCRIPTNAME]
3132

32-
# An empty PYTHONSCRIPT_SCRIPTPATH indicate that this script is not saved and will be deleted once Cinema 4D close.
33+
# An empty PYTHONSCRIPT_SCRIPTPATH indicates that this script has not been
34+
# saved and will be deleted once Cinema 4D closes.
3335
scriptPath = newScript[c4d.PYTHONSCRIPT_SCRIPTPATH]
3436

35-
# PYTHONSCRIPT_TEXT returns the python script visible in hte Script Manager.
37+
# PYTHONSCRIPT_TEXT returns the Python script visible in the Script Manager.
3638
scriptContent = newScript[c4d.PYTHONSCRIPT_TEXT]
3739

38-
print(f"Added '{scriptName}', it's content in the Script Manager is:\n{scriptContent}")
40+
print(f"Added '{scriptName}', its content in the Script Manager is:\n{scriptContent}")
3941

4042

4143
def LoadExistingPythonScript():
4244
"""Load an existing Python file into the Script Manager.
4345
"""
4446
scriptPathToLoad = os.path.join(os.path.dirname(__file__), "reg_plugin_info_r23.py")
4547

46-
# Load the script in the script manager and set it as active automatically
48+
# Load the script into the Script Manger and set it automatically as the active script.
4749
loadedScript = c4d.LoadPythonScript(scriptPathToLoad)
4850

49-
# ScriptObject being BaseList2D the usual C4DAtom bracket operator can be used to access various properties from it.
51+
# Due to the type ScriptObject being derived from BaseList2D, the bracket operator syntax can be used to access
52+
# the parameters of an instance.
5053
scriptName = loadedScript[c4d.PYTHONSCRIPT_SCRIPTNAME]
5154

52-
# An empty PYTHONSCRIPT_SCRIPTPATHindicate that this script is not saved and will be deleted once Cinema 4D close.
55+
# An empty PYTHONSCRIPT_SCRIPTPATH indicates that this script has not been
56+
# saved and will be deleted once Cinema 4D closes.
5357
scriptPath = loadedScript[c4d.PYTHONSCRIPT_SCRIPTPATH]
5458

55-
# PYTHONSCRIPT_TEXT returns the python script visible in hte Script Manager.
59+
# PYTHONSCRIPT_TEXT returns the Python script visible in the Script Manager.
5660
scriptContent = loadedScript[c4d.PYTHONSCRIPT_TEXT]
5761

5862
print(f"Load '{scriptName}', from '{scriptPath}' it's content in the Script Manager is:\n{scriptContent}")
5963

6064

6165
def SetActiveScript():
62-
"""Retrieve the first script not active in the script manager and make it active.
66+
"""Retrieve the first non-active script in the Script Manager and set it as the active script.
6367
64-
Scripts available in the script manager are BaseList2D stored into a specific GeListHead.
68+
Scripts visible in the Script Manager are represented by BaseList2D instances stored under a GeListHead.
6569
"""
6670
def HierarchyIterator(obj):
67-
"""A Python Generator to iterate over the Hierarchy.
71+
"""Yields nodes from a GeListNode tree.
6872
Args:
6973
obj: The starting object of the python generator (will be the first result)
7074
Returns:
@@ -79,26 +83,28 @@ def HierarchyIterator(obj):
7983
# Retrieve the script list head.
8084
scriptHead = c4d.GetScriptHead()
8185

82-
# Retrieve the first script not active in the script manager and make it active.
83-
# A script is active when it has its code displayed in the script manager.
86+
# Retrieve the first non-active script in the Script Manager and set it as the active script.
87+
# A script is active when it has its code displayed in the Script Manager.
8488
for scriptOp in HierarchyIterator(scriptHead.GetFirst()):
85-
# Go to the next script object if the script is already active in the script manager.
89+
# Go to the next script object if the script is already active in the Script Manager.
8690
if scriptOp.GetBit(c4d.BIT_ACTIVE):
8791
continue
8892

8993
# Retrieve the unique plugin ID generated by Cinema 4D for this script.
9094
scriptId = c4d.GetDynamicScriptID(scriptOp)
9195

92-
# Define this script as the new script to be active in the script manager.
96+
# Set the script with the ID #scriptID as the new active script
9397
c4d.SetActiveScriptObject(scriptId)
9498

95-
# ScriptObject being BaseList2D the usual C4DAtom bracket operator can be used to access various properties from it.
99+
# Due to the type ScriptObject being derived from BaseList2D, the bracket operator syntax can be used to access
100+
# the parameters of an instance.
96101
scriptName = scriptOp[c4d.PYTHONSCRIPT_SCRIPTNAME]
97102

98-
# An empty PYTHONSCRIPT_SCRIPTPATH indicate that this script is not saved and will be deleted once Cinema 4D close.
103+
# An empty PYTHONSCRIPT_SCRIPTPATH indicates that this script has not been
104+
# saved and will be deleted once Cinema 4D closes.
99105
scriptPath = scriptOp[c4d.PYTHONSCRIPT_SCRIPTPATH]
100106

101-
# PYTHONSCRIPT_TEXT returns the python script visible in hte Script Manager.
107+
# PYTHONSCRIPT_TEXT returns the Python script visible in the Script Manager.
102108
scriptContent = scriptOp[c4d.PYTHONSCRIPT_TEXT]
103109

104110
print(f"Set as active '{scriptName}', saved in `{scriptPath}` with the next content in"

0 commit comments

Comments
 (0)