Message 1 of 17
def function inside the main python script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I would like to use an "inner" function in python multiple times to create a more advanced script where I do not need to use the same lines over and over again. But it seems anything created in the "inner" function does not exist in the main, outer script. Is there any solution for this?
A very simple example here:
from varmain.primitiv import *
from varmain.custom import *
from math import *
@activate(Group="Support", TooltipShort="Class1", TooltipLong="Class1", LengthUnit="mm", Ports="1")
@group("MainDimensions")
@param(D=LENGTH, TooltipLong="length of box")
def Class1(s,D=50.0,**kw):
def Inner():
o1=BOX(s,L=D,H=D,W=D)
return o1
Inner()
#up to this line the scripts runs smoothly, the box is generated by the "Inner" function with sides "D"
o1.translate((0,10,0))
#this translate generates and error because "o1" object seems to be not existing outside the inner function
s.setPoint((0,0,0),(1,0,0))
