SysIDE Class Names
This example shows how you can use syside.sexp
function to print the symbolic
expression of the document to see what elements it contains and, most importantly, names
of the SysIDE Python classes.
Note
Before running this example, make sure you have activated the SysIDE license by
running syside-license check
according to the instructions in the
License Activation section.
Example Model
package Car {
part def Wheel {
doc /* This is a wheel*/
}
part wheels: Wheel[4] ordered;
}
Example Script
import pathlib
import syside
EXAMPLE_DIR = pathlib.Path(__file__).parent
MODEL_FILE_PATH = EXAMPLE_DIR / "example_model.sysml"
def main() -> None:
(
model,
diagnostics,
) = syside.load_model(paths=[MODEL_FILE_PATH])
# Only errors cause an exception. SysIDE may also report warnings and
# informational messages, but not for this example.
assert not diagnostics.contains_errors(warnings_as_errors=True)
for doc in model.user_docs:
# Since SysIDE is a multi-threaded application, we need to lock the
# document to ensure that the document is not modified from another
# thread while we are accessing it.
with doc.lock() as locked:
print("Model sexp:")
print(syside.sexp(locked.root_node))
if __name__ == "__main__":
main()
Output
Model sexp:
(Namespace
(OwningMembership
(Package Car
(OwningMembership
(PartDefinition Wheel
(Subclassification)
(OwningMembership
(Documentation))))
(OwningMembership
(PartUsage wheels
(OwningMembership
(MultiplicityRange
(Subsetting)
(OwningMembership
(LiteralInteger
(Subsetting)))))
(FeatureTyping)
(Subsetting))))))
Download
Download this example here.