SBPath#
This class describes a structural path, i.e. a trajectory of atoms (samson.SBAtom).
You can add, insert, and remove a conformation and parts of a path using samson.SBPath.add(), samson.SBPath.insert(), and samson.SBPath.remove() functions respectively.
You can also add, insert, and remove atoms using samson.SBPath.addAtom(), samson.SBPath.insertAtom(), and samson.SBPath.removeAtom() functions respectively.
You can also get and set position, velocity, and force data for all atoms in a path or for a particular atom.
You can get a node indexer of atoms in the conformation:
# get all paths in the active document
pathIndexer = SAMSON.getNodes('node.type path')
if len(pathIndexer):
# get the first conformation
path = pathIndexer[0]
# get an indexer of atoms in the path
atomIndexer = path.getAtomIndexer()
You can create a conformation from a path for a particular step:
# create a conformation from the first step in the path
conformationIndexer = path.createConformation(0)
conformation = conformationIndexer[0]
# name the conformation
conformation.name = "Initial state"
# turn the undo system on
with SAMSON.holding("Add new conformation"):
# hold the cloned folder instance
SAMSON.hold(conformation)
# create the cloned folder
conformation.create()
# add the conformation to the active document
SAMSON.getActiveDocument().addChild(conformation)
You can set the current step in a path:
# make the operation undoable
with SAMSON.holding("Change path step"):
# set the current step of the path to 10
path.currentStep = 10
You can go through a path to visualize it in SAMSON’s viewport as follows:
# make the operation undoable
with SAMSON.holding("Change path steps"):
# set the step duration in seconds
path.stepDuration = SBQuantity.second(0.05)
# go through all the steps in the path
for step in range(path.numberOfSteps):
path.currentStep = step
# request SAMSON to process events
SAMSON.processEvents()
See also
SAMSON SDK: SBMStructuralModelPath
- class samson.SBPath(*args, **kwargs)#
Bases:
SBNodeThis class describes a structural path.
Overloaded function.
__init__(self: samson.SBPath) -> None
Constructs a structural model path
__init__(self: samson.SBPath, name: str, nodeIndexer: samson.SBNodeIndexer) -> None
Constructs a structural model path with the given name from the conformations in nodeIndexer.
- Parameters:
name (str) – A name of the path
nodeIndexer (samson.SBNodeIndexer) – An indexer with conformations.
- class AnimationType(self: samson.SBPath.AnimationType, value: int)#
Bases:
pybind11_objectMembers:
Once : Animate once
Loop : Animate in loops
Bounce : Animate in bouncing loops
- Bounce = <AnimationType.Bounce: 3>#
- Loop = <AnimationType.Loop: 2>#
- Once = <AnimationType.Once: 1>#
- property name#
- property value#
- add(*args, **kwargs)#
Overloaded function.
add(self: samson.SBPath, conformation: samson.SBConformation) -> bool
Adds a frame to the path
add(self: samson.SBPath, path: samson.SBPath) -> bool
Adds frames to the path
add(self: samson.SBPath, positionData: list[samson.SBPhysicalVector3], energy: samson.SBQuantity.unitsSI = 0 (dimensionless), time: samson.SBQuantity.unitsSI = 0 (dimensionless), velocityData: list[samson.SBPhysicalVector3] = [], forceData: list[samson.SBPhysicalVector3] = []) -> bool
Adds a frame to the path
add(self: samson.SBPath, positionData: list[list[samson.SBPhysicalVector3]], energyData: list[samson.SBQuantity.unitsSI] = [], timeData: list[samson.SBQuantity.unitsSI] = [], velocityData: list[list[samson.SBPhysicalVector3]] = [], forceData: list[list[samson.SBPhysicalVector3]] = []) -> bool
Adds frames to the path
- addAtom(self: samson.SBPath, atom: SBMStructuralModelNodeAtom, atomPositionVector: list[samson.SBPhysicalVector3] = [], atomVelocityVector: list[samson.SBPhysicalVector3] = [], atomForceVector: list[samson.SBPhysicalVector3] = []) bool#
Adds an atom to the path
- copy(self: samson.SBPath, firstStep: int, lastStep: int) samson.SBPath#
Copies frames from the path to create a new path
- createConformation(self: samson.SBPath, step: int) samson.SBNodeIndexer#
Create a conformation corresponding to a specific step
- createConformations(self: samson.SBPath) samson.SBNodeIndexer#
Create conformations corresponding to all steps
- createStructuralModels(*args, **kwargs)#
Overloaded function.
createStructuralModels(self: samson.SBPath, step: int) -> samson.SBNodeIndexer
Create structural models corresponding to a specific step
createStructuralModels(self: samson.SBPath) -> samson.SBNodeIndexer
Create structural models corresponding to all steps
- getAtomIndexer(self: samson.SBPath) samson.SBNodeIndexer#
Returns the indexer of atoms for which a position is saved.
- Returns:
A node indexer with the associated atoms.
- Return type:
- getEnergy(self: samson.SBPath, step: int) samson.SBQuantity.unitsSI#
Returns the energy for a specific step
- getEnergyData(self: samson.SBPath) list[samson.SBQuantity.unitsSI]#
Returns the energy data
- getForce(*args, **kwargs)#
Overloaded function.
getForce(self: samson.SBPath, step: int, atomIndex: int) -> samson.SBPhysicalVector3
Returns the force of atom with atomIndex for a specific step
getForce(self: samson.SBPath, step: int, atom: SBMStructuralModelNodeAtom) -> samson.SBPhysicalVector3
Returns the force of atom for a specific step
- getForceData(self: samson.SBPath) list[list[samson.SBPhysicalVector3]]#
Returns the force array: 2D array, (number of timesteps) x (number of structural nodes)
- getNextPath(self: samson.SBPath) samson.SBPath#
Returns the next path in the document
- getPosition(*args, **kwargs)#
Overloaded function.
getPosition(self: samson.SBPath, step: int, atomIndex: int) -> samson.SBPhysicalVector3
Returns the position of atom with atomIndex for a specific step
getPosition(self: samson.SBPath, step: int, atom: SBMStructuralModelNodeAtom) -> samson.SBPhysicalVector3
Returns the position of atom for a specific step
- getPositionData(self: samson.SBPath) list[list[samson.SBPhysicalVector3]]#
Returns the position array: 2D array, (number of timesteps) x (number of structural nodes)
- getPreviousPath(self: samson.SBPath) samson.SBPath#
Returns the previous path in the document
- getTime(self: samson.SBPath, step: int) samson.SBQuantity.unitsSI#
Returns the time for a specific step
- getTimeData(self: samson.SBPath) list[samson.SBQuantity.unitsSI]#
Returns the time data
- getVelocity(*args, **kwargs)#
Overloaded function.
getVelocity(self: samson.SBPath, step: int, atomIndex: int) -> samson.SBPhysicalVector3
Returns the velocity of atom with atomIndex for a specific step
getVelocity(self: samson.SBPath, step: int, atom: SBMStructuralModelNodeAtom) -> samson.SBPhysicalVector3
Returns the velocity of atom for a specific step
- getVelocityData(self: samson.SBPath) list[list[samson.SBPhysicalVector3]]#
Returns the velocity array: 2D array, (number of timesteps) x (number of structural nodes)
- hasEnergyData(self: samson.SBPath) bool#
Returns whether the path has the energy data
- hasForceData(self: samson.SBPath) bool#
Returns whether the path has the force data
- hasPositionData(self: samson.SBPath) bool#
Returns whether the path has the position data
- hasTimeData(self: samson.SBPath) bool#
Returns whether the path has the time data
- hasVelocityData(self: samson.SBPath) bool#
Returns whether the path has the velocity data
- insert(*args, **kwargs)#
Overloaded function.
insert(self: samson.SBPath, step: int, conformation: samson.SBConformation) -> bool
Inserts a frame to the path at the step
insert(self: samson.SBPath, step: int, path: samson.SBPath) -> bool
Inserts frames to the path starting from the step
insert(self: samson.SBPath, step: int, positionData: list[samson.SBPhysicalVector3], energy: samson.SBQuantity.unitsSI = 0 (dimensionless), time: samson.SBQuantity.unitsSI = 0 (dimensionless), velocityData: list[samson.SBPhysicalVector3] = [], forceData: list[samson.SBPhysicalVector3] = []) -> bool
Inserts a frame in the path at position step
insert(self: samson.SBPath, step: int, positionData: list[list[samson.SBPhysicalVector3]], energyData: list[samson.SBQuantity.unitsSI] = [], timeData: list[samson.SBQuantity.unitsSI] = [], velocityData: list[list[samson.SBPhysicalVector3]] = [], forceData: list[list[samson.SBPhysicalVector3]] = []) -> bool
Inserts frames in the path at position step
- insertAtom(self: samson.SBPath, atomIndex: int, atom: SBMStructuralModelNodeAtom, atomPositionVector: list[samson.SBPhysicalVector3] = [], atomVelocityVector: list[samson.SBPhysicalVector3] = [], atomForceVector: list[samson.SBPhysicalVector3] = []) bool#
Inserts an atom at index atomIndex to the path
- remove(*args, **kwargs)#
Overloaded function.
remove(self: samson.SBPath, step: int) -> samson.SBConformation
Remove a frame from the path to create a conformation
remove(self: samson.SBPath, firstStep: int, lastStep: int) -> samson.SBPath
Removes frames from the path to create a new path
- removeAtom(self: samson.SBPath, atom: SBMStructuralModelNodeAtom) bool#
Removes an atom from the path
- setEnergy(self: samson.SBPath, step: int, energy: samson.SBQuantity.unitsSI) None#
Sets the energy for a specific step
- setEnergyData(self: samson.SBPath, energyData: list[samson.SBQuantity.unitsSI]) None#
Sets the energy data
- setForce(*args, **kwargs)#
Overloaded function.
setForce(self: samson.SBPath, step: int, atomIndex: int, force: samson.SBPhysicalVector3) -> None
Sets the force of atom with atomIndex to position for a specific step
setForce(self: samson.SBPath, step: int, atom: SBMStructuralModelNodeAtom, force: samson.SBPhysicalVector3) -> None
Sets the force of atom to position for a specific step
- setForceData(self: samson.SBPath, forceData: list[list[samson.SBPhysicalVector3]]) None#
Sets the force array: 2D array, (number of timesteps) x (number of structural nodes)
- setPosition(*args, **kwargs)#
Overloaded function.
setPosition(self: samson.SBPath, step: int, atomIndex: int, position: samson.SBPhysicalVector3) -> None
Sets the position of atom with atomIndex to position for a specific step
setPosition(self: samson.SBPath, step: int, atom: SBMStructuralModelNodeAtom, position: samson.SBPhysicalVector3) -> None
Sets the position of atom to position for a specific step
- setPositionData(self: samson.SBPath, positionData: list[list[samson.SBPhysicalVector3]]) None#
Sets the position array: 2D array, (number of timesteps) x (number of structural nodes)
- setTime(self: samson.SBPath, step: int, time: samson.SBQuantity.unitsSI) None#
Sets the time for a specific step
- setTimeData(self: samson.SBPath, timeData: list[samson.SBQuantity.unitsSI]) None#
Sets the time data
- setVelocity(*args, **kwargs)#
Overloaded function.
setVelocity(self: samson.SBPath, step: int, atomIndex: int, velocity: samson.SBPhysicalVector3) -> None
Sets the velocity of atom with atomIndex to position for a specific step
setVelocity(self: samson.SBPath, step: int, atom: SBMStructuralModelNodeAtom, velocity: samson.SBPhysicalVector3) -> None
Sets the velocity of atom to position for a specific step
- setVelocityData(self: samson.SBPath, velocityData: list[list[samson.SBPhysicalVector3]]) None#
Sets the velocity array: 2D array, (number of timesteps) x (number of structural nodes)
- updateState(self: samson.SBPath) None#
Updates the state along the path according to the animation parameters
- Bounce = <AnimationType.Bounce: 3>#
- Loop = <AnimationType.Loop: 2>#
- Once = <AnimationType.Once: 1>#
- property animationFlag#
The animation flag
- property animationType#
The animation type
- property currentEnergy#
The current energy
- property currentStep#
The current step along the path
- property currentTime#
The current time
- property forwardFlag#
The forward flag, which indicates when the animation is moving forward
- property numberOfAtoms#
The number of atoms for which a position is saved
- property numberOfSteps#
The number of steps in the path
- property smoothingWindowSize#
The size of the smoothing window
- property sourceFileName#
The source file name
- property stepDuration#
The step duration
- property stride#
The animation stride