Install the library:
pip install sysml2py
A PackageBuilder is the top-level container. Add Parts, and give each part children with add():
PackageBuilder
Part
add()
from sysml2py import PackageBuilder, Part, Attribute pkg = PackageBuilder('MyModel') stage = Part('Stage_1') stage.add(Attribute('mass')) stage.add(Attribute('thrust')) pkg.add(stage) print(pkg.dump())
package MyModel { part Stage_1 { attribute mass; attribute thrust; } }
PackageBuilder('MyModel')
package
Part('Stage_1')
part
stage.add(Attribute('mass'))
attribute
pkg.add(stage)
pkg.dump()
Because these are builders, you can print any one of them directly:
>>> Part('Stage_1').dump() 'part Stage_1;'
A bare Part('Stage_1') is a usage in SysML terms. Ask for a definition with kind=:
kind=
>>> Part('Stage_1', kind='definition').dump() 'part def Stage_1;'
Some kinds have no definition form — the generator refuses rather than emit something it can't cast back (see The Builder API).
There was an error while loading. Please reload this page.