def ParseParameters(*args):
Result = []
Parameters = ""
+ hasVariables = False
varModifFun=None
if args and callable( args[-1] ):
args, varModifFun = args[:-1], args[-1]
if not notebook.isVariable(parameter):
raise ValueError, "Variable with name '" + parameter + "' doesn't exist!!!"
parameter = notebook.get(parameter)
+ hasVariables = True
if varModifFun:
parameter = varModifFun(parameter)
pass
pass
Parameters = Parameters[:-1]
Result.append( Parameters )
+ Result.append( hasVariables )
return Result
# Parse parameters converting variables to radians
# Substitute PointStruct.__init__() to create SMESH.PointStruct using notebook variables.
# Parameters are stored in PointStruct.parameters attribute
def __initPointStruct(point,*args):
- point.x, point.y, point.z, point.parameters = ParseParameters(*args)
+ point.x, point.y, point.z, point.parameters,hasVars = ParseParameters(*args)
pass
SMESH.PointStruct.__init__ = __initPointStruct
# Substitute AxisStruct.__init__() to create SMESH.AxisStruct using notebook variables.
# Parameters are stored in AxisStruct.parameters attribute
def __initAxisStruct(ax,*args):
- ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters = ParseParameters(*args)
+ ax.x, ax.y, ax.z, ax.vx, ax.vy, ax.vz, ax.parameters,hasVars = ParseParameters(*args)
pass
SMESH.AxisStruct.__init__ = __initAxisStruct
for i,m in enumerate(meshes):
if isinstance(m, Mesh):
meshes[i] = m.GetMesh()
- mergeTolerance,Parameters = ParseParameters(mergeTolerance)
+ mergeTolerance,Parameters,hasVars = ParseParameters(mergeTolerance)
meshes[0].SetParameters(Parameters)
if allGroups:
aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
# @return Id of the new node
# @ingroup l2_modif_add
def AddNode(self, x, y, z):
- x,y,z,Parameters = ParseParameters(x,y,z)
- self.mesh.SetParameters(Parameters)
+ x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
+ if hasVars: self.mesh.SetParameters(Parameters)
return self.editor.AddNode( x, y, z)
## Creates a 0D element on a node with given number.
# @return True if succeed else False
# @ingroup l2_modif_movenode
def MoveNode(self, NodeID, x, y, z):
- x,y,z,Parameters = ParseParameters(x,y,z)
- self.mesh.SetParameters(Parameters)
+ x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
+ if hasVars: self.mesh.SetParameters(Parameters)
return self.editor.MoveNode(NodeID, x, y, z)
## Finds the node closest to a point and moves it to a point location
# @return the ID of a node
# @ingroup l2_modif_throughp
def MoveClosestNodeToPoint(self, x, y, z, NodeID):
- x,y,z,Parameters = ParseParameters(x,y,z)
- self.mesh.SetParameters(Parameters)
+ x,y,z,Parameters,hasVars = ParseParameters(x,y,z)
+ if hasVars: self.mesh.SetParameters(Parameters)
return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
## Finds the node closest to a point
MaxNbOfIterations, MaxAspectRatio, Method):
if IDsOfElements == []:
IDsOfElements = self.GetElementsId()
- MaxNbOfIterations,MaxAspectRatio,Parameters = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
+ MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
self.mesh.SetParameters(Parameters)
return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
MaxNbOfIterations, MaxAspectRatio, Method)
MaxNbOfIterations, MaxAspectRatio, Method):
if IDsOfElements == []:
IDsOfElements = self.GetElementsId()
- MaxNbOfIterations,MaxAspectRatio,Parameters = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
+ MaxNbOfIterations,MaxAspectRatio,Parameters,hasVars = ParseParameters(MaxNbOfIterations,MaxAspectRatio)
self.mesh.SetParameters(Parameters)
return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
MaxNbOfIterations, MaxAspectRatio, Method)
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
AngleInRadians,AngleParameters = ParseAngles(AngleInRadians)
- NbOfSteps,Tolerance,Parameters = ParseParameters(NbOfSteps,Tolerance)
+ NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if TotalAngle and NbOfSteps:
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
AngleInRadians,AngleParameters = ParseAngles(AngleInRadians)
- NbOfSteps,Tolerance,Parameters = ParseParameters(NbOfSteps,Tolerance)
+ NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if TotalAngle and NbOfSteps:
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
AngleInRadians,AngleParameters = ParseAngles(AngleInRadians)
- NbOfSteps,Tolerance,Parameters = ParseParameters(NbOfSteps,Tolerance)
+ NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if TotalAngle and NbOfSteps:
if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
Axis = self.smeshpyD.GetAxisStruct(Axis)
AngleInRadians,AngleParameters = ParseAngles(AngleInRadians)
- NbOfSteps,Tolerance,Parameters = ParseParameters(NbOfSteps,Tolerance)
+ NbOfSteps,Tolerance,Parameters,hasVars = ParseParameters(NbOfSteps,Tolerance)
Parameters = Axis.parameters + var_separator + AngleParameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if TotalAngle and NbOfSteps:
IDsOfElements = self.GetElementsId()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
- NbOfSteps,Parameters = ParseParameters(NbOfSteps)
+ NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
Parameters = StepVector.PS.parameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if MakeGroups:
theObject = theObject.GetMesh()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
- NbOfSteps,Parameters = ParseParameters(NbOfSteps)
+ NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
Parameters = StepVector.PS.parameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if MakeGroups:
theObject = theObject.GetMesh()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
- NbOfSteps,Parameters = ParseParameters(NbOfSteps)
+ NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
Parameters = StepVector.PS.parameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if MakeGroups:
theObject = theObject.GetMesh()
if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
StepVector = self.smeshpyD.GetDirStruct(StepVector)
- NbOfSteps,Parameters = ParseParameters(NbOfSteps)
+ NbOfSteps,Parameters,hasVars = ParseParameters(NbOfSteps)
Parameters = StepVector.PS.parameters + var_separator + Parameters
self.mesh.SetParameters(Parameters)
if MakeGroups:
def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
decrFun = lambda i: i-1
- theNodeIndexOnKeyPoint1,Parameters = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
+ theNodeIndexOnKeyPoint1,Parameters,hasVars = ParseParameters(theNodeIndexOnKeyPoint1, decrFun)
theMesh.SetParameters(Parameters)
return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
decrFun = lambda i: i-1
- theNode000Index,theNode001Index,Parameters = ParseParameters(theNode000Index,theNode001Index, decrFun)
+ theNode000Index,theNode001Index,Parameters,hasVars = ParseParameters(theNode000Index,theNode001Index, decrFun)
theMesh.SetParameters(Parameters)
return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
#print "MethWrapper.__call__",self.method.__name__, args
try:
parsed = ParseParameters(*args) # replace variables with their values
- self.hyp.SetVarParameter( parsed[-1], self.method.__name__ )
- result = self.method( self.hyp, *parsed[:-1] ) # call hypothesis method
+ self.hyp.SetVarParameter( parsed[-2], self.method.__name__ )
+ result = self.method( self.hyp, *parsed[:-2] ) # call hypothesis method
except omniORB.CORBA.BAD_PARAM: # raised by hypothesis method call
# maybe there is a replaced string arg which is not variable
result = self.method( self.hyp, *args )