INDX INDEX_SECTIONM\Sop/inline_pycode]M\Object/inline_pycode,) MDop/inline_pycodeG9M inline_pycodeInline Python Code*oplib:/Sop/inline_pycode?Sop/inline_pycode MISC_pythonSopM\ inline_pycodeInline Python Code0oplib:/Object/inline_pycode?Object/inline_pycode MISC_pythonObjectM inline_pycodeInline Python Code*oplib:/Dop/inline_pycode?Dop/inline_pycode MISC_pythonDopMINDX DialogScript&M\ PythonCook&M\TypePropertiesOptions M\Help M\ Tools.shelfM\ CreateScript y"M\Version Mį PythonModule ~M OnCreated MExtraFileOptionsFM\Credits&M\# Dialog script for inline_pycode automatically generated 05/07/11 07:52:59 { name inline_pycode script inline_pycode label "Inline Python Code" help { "" } parm { name "code" label "Inline Code" type string default { [ "" python ] } range { 0 1 } export none } parm { name "create" label "Create New Operator" type button default { [ "1" python ] } range { 0 1 } export none parmtag { "script_callback_language" "python" } parmtag { "script_callback" "hou.phm().createNewOperator(kwargs)" } } } # # Produced by: # Graham Thompson # captainhammy@gmail.com # www.captainhammy.com # # Description: # PythonCook section for Inline Python Code SOP. # code = hou.pwd().parm("code").expression() exec codeParmsFromVfl := 0; PrefixDroppedParmName := 1; UseDSParms := 1; ForbidOutsideParms := 1; LockContents := 1; SaveSpareParms := 0; CheckExternal := 1; GzipContents := 1; MakeDefault := 1; SaveCachedCode := 0; PrefixDroppedParmLabel := 1; UnlockOnCreate := 0; #type: node #context: sop #internal: inline_pycode #icon: MISC/python = Inline Python Code = """Write Python code that is put directly into your geometry network.""" This operator lets you write Python code that is put directly into your geometry network. @parameters Inline Code: Python code to modify input geometry. Create New Operator: Create a new Python operator using the inline code. @related - [Script|/nodes/sop/script] operator:Sop/inline_pycode SOP SOP $HDA_TABLE/$HDA_NAME Utility # Automatically generated script: Saturday May 07, 07:52 2011 \set noalias = 1 # # Creation script for inline_pycode operator # if ( "$arg1" == "" ) then echo This script is intended as a creation script exit endif # Node $arg1 (Sop/inline_pycode) opexprlanguage -s python $arg1 1.5# # Produced by: # Graham Thompson # captainhammy@gmail.com # www.captainhammy.com # # Description: # PythonModule section for Inline Python Code SOP. # import os def createNewOperator(scriptargs): """ Create a new Python operator from an Inline Python Code operator. This function works for SOPs, objects and DOPs. """ # The inline operator to copy. node = scriptargs["node"] # Get the parameter layout from the node. This ensures that any spare parameters # referenced by the code are available. parm_template_group = node.parmTemplateGroup() # Remove the code entry parameter and the create button from the parameter layout. parm_template_group.remove("code") parm_template_group.remove("create") # Get the node type definition of the asset node. node_type = node.type() node_type_definition = node_type.definition() # Prompt for a file path to save the new asset to. file_path = hou.expandString(hou.ui.selectFile(file_type=hou.fileType.Otl)) # Hit cancel so abort. if len(file_path) == 0: return # We selected a directory so throw an error. if os.path.isdir(file_path): raise hou.OperationFailed("Cannot save asset as a directory.") # Forgot to add the .otl extension so append one. if len(os.path.splitext(file_path)[-1]) == 0: file_path += ".otl" # If we entered 'Embedded' then set the path to just that. if os.path.split(file_path)[-1] == "Embedded": file_path = "Embedded" # Options for multi line prompt. labels = ("Operator Name", "Operator Label", "Icon") buttons = ("OK", "Cancel") defaults = ("", "", "MISC_python") # Get some operator information. choices = hou.ui.readMultiInput("Create new operator from inline operator.", labels, buttons=buttons, initial_contents=defaults) # If we wanted to cancel then abort. if choices[0] == 1: return # If any of the options were left blank then abort. for value in choices[1]: if len(value) == 0: return # Separate out the choices. op_name, op_label, icon = choices[1] # Copy the existing asset to the new file and set the new operator info. node_type_definition.copyToHDAFile(file_path, op_name, op_label) # Install the file with the new asset into the scene. hou.hda.installFile(file_path) # Get the definition of the new asset. asset_def = hou.hda.definitionsInFile(file_path)[-1] # Set the icon. asset_def.setIcon(icon) # Apply the parameter layout. asset_def.setParmTemplateGroup(parm_template_group) # Remove old extra sections. asset_def.removeSection("PythonModule") asset_def.removeSection("Credits") asset_def.removeSection("OnCreated") asset_def.removeSection("Help") # Get the code we are running inline and assign it to the cook code of the # new operator. code = node.parm("code").expression() asset_def.sections()["PythonCook"].setContents(code) # Return the asset definition incase we need to do any type specific post processing. return asset_def# # Produced by: # Graham Thompson # captainhammy@gmail.com # www.captainhammy.com # # Description: # OnCreated section for Inline Python Code SOP. # sopnode = kwargs["node"] # Set the nodes expression language to be Python so we can set the parameter code. sopnode.setExpressionLanguage(hou.exprLanguage.Python) # The default inline code. sopnode.parm("code").setExpression("sopnode = hou.pwd()\ngeo = sopnode.geometry()") Credits/IsExprCredits/IsPythonCredits/IsScriptCredits/SourceOnCreated/IsExprOnCreated/IsPythonOnCreated/IsScriptOnCreated/SourcePythonModule/IsExprPythonModule/IsPythonPythonModule/IsScriptPythonModule/SourceProduced by: Graham Thompson captainhammy@gmail.com www.captainhammy.com Name: multi_inline_pycode.otl Version: 1.5 Compatibility: Houdini 11.0 Changes: v1.5: Added the ability to create a new digital asset from an inline operator.INDX DialogScript M PythonCook MTypePropertiesOptions MHelp M Tools.shelfM Contents.gz+ M CreateScript&MVersionM PythonModule M OnCreated"MExtraFileOptions%{FMCredits&M# Dialog script for inline_pycode automatically generated 05/04/11 14:27:40 { name inline_pycode script inline_pycode label "Inline Python Code" help { "" } parm { name "code" label "Inline Code" type string default { [ "" python ] } range { 0 1 } export none } group { name "stdswitcher3" label "Transform" invisibletab parm { name "keeppos" baseparm invisible joinnext export none } parm { name "pre_xform" baseparm invisible export none } parm { name "xOrd" baseparm invisible joinnext export none } parm { name "rOrd" baseparm invisible export none } parm { name "t" baseparm invisible export none } parm { name "r" baseparm invisible export none } parm { name "s" baseparm invisible export none } parm { name "p" baseparm invisible export none } parm { name "scale" baseparm invisible export none } parm { name "lookatpath" baseparm invisible export none } parm { name "lookup" baseparm invisible export none } parm { name "pathobjpath" baseparm invisible export none } parm { name "roll" baseparm invisible export none } parm { name "pos" baseparm invisible export none } parm { name "uparmtype" baseparm invisible export none } parm { name "pathorient" baseparm invisible export none } parm { name "up" baseparm invisible export none } parm { name "bank" baseparm invisible export none } } parm { name "create" label "Create New Operator" type button default { [ "1" python ] } range { 0 1 } export none parmtag { "script_callback_language" "python" } parmtag { "script_callback" "hou.phm().createNewOperator(kwargs)" } } group { name "stdswitcher3_1" label "Subnet" parm { name "label1" baseparm invisible export dialog } parm { name "label2" baseparm invisible export dialog } parm { name "label3" baseparm invisible export dialog } parm { name "label4" baseparm invisible export dialog } parm { name "tdisplay" baseparm invisible joinnext export none } parm { name "display" baseparm invisible export none } parm { name "outputobj" baseparm invisible export none } parm { name "visibleobjects" baseparm invisible export none } parm { name "picking" baseparm invisible export none } parm { name "pickscript" baseparm invisible export none } parm { name "caching" baseparm invisible export none } parm { name "use_dcolor" baseparm export none } parm { name "dcolor" baseparm export none } } } # # Produced by: # Graham Thompson # captainhammy@gmail.com # www.captainhammy.com # # Description: # PythonCook section for Inline Python Code object. # code = hou.pwd().parm("code").expression() exec codeParmsFromVfl := 0; PrefixDroppedParmName := 1; UseDSParms := 1; ForbidOutsideParms := 1; LockContents := 1; SaveSpareParms := 0; CheckExternal := 1; GzipContents := 1; MakeDefault := 1; SaveCachedCode := 0; PrefixDroppedParmLabel := 1; UnlockOnCreate := 0; #type: node #context: obj #internal: inline_pycode #icon: MISC/python = Inline Python Code = """Write Python code that is put directly into your object network.""" This operator lets you write Python code that is put directly into your object network. @parameters Inline Code: Python code to modify object transforms. Create New Operator: Create a new Python operator using the inline code. operator:Object/inline_pycode OBJ OBJ $HDA_TABLE/$HDA_NAME Utility ks6_p30?ٝLR;2sq&K&wv4QA@۪CҶIc.῝>[~F)7_b'lJrgH{KB F (^c̉ܭeW 5|Q T=@(f3;Dr1r;,yt;@rXD"DZS&"=?>{::T) oT?IK_fɔG@[rEЏH:4'dJnGO/K(S(5b :-N \OŽ4¾m!N^ q tfmp&猣~ǩ`O$k{p,xR`(FQ9IᐠttߝaÇӽ}<>;:{u1>{uǶ|4)CG}sz}4~m{9G㐰r- < az&Pkl|zL>jNEc>]LAްy-.%R ʷ|BβVcb9BNMۢxB\ضzw銐&Xhg% 0.%ĶM`pǷ9+ߞNm*aJ8nlGXz~lؗ2ve| ٦+F`2o TJDۨ# a NU5h-#d9#LIY: ~jDXR|jR ͊"D.Z'Jr[K0$o3*;XF7Bz 4 jГNbF"d|doyUq/ۻ$ĕg,E1 x%򍒁U8TA>"1Ko~Q+'@LBxi%愦H* IỤ` A*$+-$D𨨯ZeRҖF9)1W5 /VU+ ZM*5Vg @ ,MDRrBޓdP@A]P(|W0f~uZ% d]ՖlZwgKE/oKjY[yu†`,J{7_lhI яU{k q&D\Xfb9vX)Ҁ.NKJT=GtVh` IN8مNy92`lc9o:U9%LDI:sSj_! M4uqLЧGfk5z|L*{2E/%:e}ޑ(f!h׭F[Bבu![O8КCׄ 5a1|>ptZ |AuKiQЮ-e1jgJ5u K-!P}zNjV/B?04ա)}px<5A}MStV~YW$p b9XJL32*TSYugo?pyGdi]qF!Kz)EבPu75r)me}]/5蛓VJɌ5Yt~d<<2I]-Uo$;ftR+zޅ T , -H 3kA&$!ƐZYJbz(ВyNIGQG-G0M+LlRő P=5<0qIrV3L2(Z1c*:v w~m0y xk6ڪsWl;?3ڐ:ۜB^b V4)7̻:Ѩ,'{w_wEĘJus7CUx$ԇw@* \NwsJ%ˡ[ULgh"(~wMBnoO[ɷ'dU] j츆"3Fpbׂ r-uk@poցC89n`8l6s^hꬷUpr#v[+) e{uVjwh/OBB:Y}֯7P ١CEgf CS8nWj>wz-Ō9 _WV7:P'!F[ e ؠ53EqJ V[tRfLy/86Ŧ*^>ax54tqGIaZQ ˰?*m|o@͗ŹtA⨋ZF4WR0 k7J,Jc08*†dcS0JB۪@P*T6"\@(5_pR?\wNv_'=.gTXpNۚh7 Oo_]p!8# Automatically generated script: Wednesday May 04, 14:27 2011 \set noalias = 1 # # Creation script for inline_pycode operator # if ( "$arg1" == "" ) then echo This script is intended as a creation script exit endif # Node $arg1 (Object/inline_pycode) opexprlanguage -s python $arg1 1.5# # Produced by: # Graham Thompson # captainhammy@gmail.com # www.captainhammy.com # # Description: # PythonModule section for Inline Python Code object. # def createNewOperator(scriptargs): # Get the node type definition of the SOP version of this object. sop_node_type = hou.nodeType(hou.sopNodeTypeCategory(), kwargs["type"].name()) # Create the new asset from this node. asset_def = sop_node_type.hdaModule().createNewOperator(scriptargs) # The OnCreated script to set the color and selectability. oncreated_script = """objnode = kwargs[\"node\"] objnode.setSelectableInViewport(False) objnode.parmTuple(\"dcolor\").set((0, 0.75, 0))""" # Add a new section for the OnCreated script and assign its contents. section = asset_def.addSection("OnCreated") section.setContents(oncreated_script) # Tell the asset to treat the OnCreated section as Python. asset_def.setExtraFileOption("OnCreated/IsPython", True)# # Produced by: # Graham Thompson # captainhammy@gmail.com # www.captainhammy.com # # Description: # OnCreated section for Inline Python Code object. # objnode = kwargs["node"] # Set the nodes expression language to be Python so we can set the parameter code. objnode.setExpressionLanguage(hou.exprLanguage.Python) # Set the customary green object color. objnode.parmTuple("dcolor").set((0, 0.75, 0)) # Toggle off selectability in the viewport. objnode.setSelectableInViewport(False) # The default inline code. objnode.parm("code").setExpression("objnode = hou.pwd()\nxform = hou.hmath.identityTransform()\n\n\nobjnode.setCookTransform(xform)") Credits/IsExprCredits/IsPythonCredits/IsScriptCredits/SourceOnCreated/IsExprOnCreated/IsPythonOnCreated/IsScriptOnCreated/SourcePythonModule/IsExprPythonModule/IsPythonPythonModule/IsScriptPythonModule/SourceProduced by: Graham Thompson captainhammy@gmail.com www.captainhammy.com Name: multi_inline_pycode.otl Version: 1.5 Compatibility: Houdini 11.0 Changes: 1.5: Added the ability to create a new digital asset from an inline operator.INDX DialogScript'M PythonCook'MTypePropertiesOptionsMHelpM Tools.shelfM CreateScript C#M PythonModule fM OnCreated ;MExtraFileOptions FMCreditsOMVersionGM# Dialog script for inline_pycode automatically generated 05/04/11 14:27:56 { name inline_pycode script inline_pycode label "Inline Python Code" help { "" } parm { name "code" label "Inline Code" type string default { [ "" python ] } range { 0 1 } export none } parm { name "create" label "Create New Operator" type button default { [ "1" python ] } range { 0 1 } export none parmtag { "script_callback_language" "python" } parmtag { "script_callback" "hou.phm().createNewOperator(kwargs)" } } } # # Produced by: # Graham Thompson # captainhammy@gmail.com # www.captainhammy.com # # Description: # PythonCook section for Inline Python Code DOP. # code = hou.pwd().parm("code").expression() exec code ParmsFromVfl := 0; PrefixDroppedParmName := 1; UseDSParms := 1; ForbidOutsideParms := 1; LockContents := 1; SaveSpareParms := 0; CheckExternal := 1; GzipContents := 1; MakeDefault := 1; SaveCachedCode := 0; PrefixDroppedParmLabel := 1; UnlockOnCreate := 0; #type: node #context: dop #internal: inline_pycode #icon: MISC/python = Inline Python Code = """Write Python code that is put directly into your DOP network.""" This operator lets you write Python code that is put directly into your DOP network. @parameters Inline Code: Python code to modify dynamics data. Create New Operator: Create a new Python operator using the inline code. operator:Dop/inline_pycode DOP DOP $HDA_TABLE/$HDA_NAME Utility # Automatically generated script: Wednesday May 04, 14:27 2011 \set noalias = 1 # # Creation script for inline_pycode operator # if ( "$arg1" == "" ) then echo This script is intended as a creation script exit endif # Node $arg1 (Dop/inline_pycode) opexprlanguage -s python $arg1 # # Produced by: # Graham Thompson # captainhammy@gmail.com # www.captainhammy.com # # Description: # PythonModule section for Inline Python Code DOP. # def createNewOperator(scriptargs): # Get the node type definition of the SOP version of this object. sop_node_type = hou.nodeType(hou.sopNodeTypeCategory(), kwargs["type"].name()) # Create the new asset from this node. sop_node_type.hdaModule().createNewOperator(scriptargs) # # Produced by: # Graham Thompson # captainhammy@gmail.com # www.captainhammy.com # # Description: # OnCreated section for Inline Python Code DOP. # dopnode = kwargs["node"] # Set the nodes expression language to be Python so we can set the parameter code. dopnode.setExpressionLanguage(hou.exprLanguage.Python) # The default inline code dopnode.parm("code").setExpression("dopnode = hou.pwd()\nobjects = dopnode.objectsToProcess()\n") Credits/IsExprCredits/IsPythonCredits/IsScriptCredits/SourceOnCreated/IsExprOnCreated/IsPythonOnCreated/IsScriptOnCreated/SourcePythonModule/IsExprPythonModule/IsPythonPythonModule/IsScriptPythonModule/SourceProduced by: Graham Thompson captainhammy@gmail.com www.captainhammy.com Name: multi_inline_pycode.otl Version: 1.5 Compatibility: Houdini 11.0 Changes: 1.5: Added the ability to create a new digital asset from an inline operator.1.5