System
System
Class System()
System(parent='MODEL', name='System_n', label='System_n', active=True,
definition_name='def_sys_n', definition_file='', definition_type='', use_vx=False,
use_vy=False, use_vz=False, use_wx=False, use_wy=False, use_wz=False, vx=0, vy=0,
vz=0, wx=0, wy=0, wz=0)
Creates a MotionView system to hold different entities.
addAttachment, addDataSet, getAttachments, getCandidateList, getValue, setValue
Keyword Arguments
Argument | Data Type | Description | Default |
---|---|---|---|
name | String | The variable name. | System_n, for next available integer n. |
label | String | The descriptive label. | System_n, for next available integer n. |
parent | Object | The parent. | MODEL |
active | Boolean | Used to activate or deactivate this entity. | True |
definition_name | String | The definition name of system. | def_sys_n for next available integer n. |
definition_file | String | The full path of a file when the definition name is defined in a definition file. Defaults to ‘'. * definition_type (String) - Definition type of this system. | ‘' |
use_vx | Bool | Use initial translation velocity in x for bodies inside this system. | False |
use_vy | Bool | Use initial translation velocity in y for bodies inside this system. | False |
use_vz | Bool | Use initial translation velocity in z for bodies inside this system. | False |
use_wx | Bool | Use initial rotational velocity in x for bodies inside this system. | False |
use_wy | Bool | Use initial rotational velocity in y for bodies inside this system. | False |
use_wz | Bool | Use initial rotational velocity in z for bodies inside this system. | False |
vx | Double | Initial translation velocity in x for bodies inside this system. | 0 |
vy | Double | Initial translation velocity in y for bodies inside this system. | 0 |
vz | Double | Initial translation velocity in z for bodies inside this system. | 0 |
wx | Double | Initial rotational velocity in x for bodies inside this system. | 0 |
wy | Double | Initial rotational velocity in y for bodies inside this system. | 0 |
wz | Double | Initial rotational velocity in z for bodies inside this system. | 0 |
Readonly Properties
Argument | Data Type | Description | |
---|---|---|---|
definition_file_modified | Bool | Specifies if the definition is modified after loading it. | |
linked_definitions | Reference | List of system handles which have share the same definition name. | |
is_linked | Bool | Indicates whether definition name of this system is used by any other system in the model. | |
atts | Dict | Dictionary of all attachment's local variable names and their handles. | |
dss | Dict | Dictionary of all dataset's variable names and their handles which are inside this system. | |
datas | Dict | Dictionary of all option's variable names and their handles which are on this system. |
Notes
1. The parent parameter can only be initialized by the constructor and should not be modified directly.
2. Only parent can be used as a positional argument in the constructor.
3. Readonly Properties cannot be modified.
Methods
- addAttachment(type='Point', value=None, candidate_tag='', **kwds)
-
Adds an attachment or a list of attachments to the entity.
Parameters:
type str Class name of the attachment to be added. Point if not specified. value ** Value the attachment(entity handle) should be resolved to. None candidate_tag String Candidate tag for this attachment. att_list dict Dictionary of attachment variable names and attachments values. If you specify this argument you do not need any other argument. name String Variable name of the attachment that is to be added. If the attachment with that name already exists then the attachment's value will be changed to specified value. Returns:
Returns None.
Return type:
None
- addDataSet(**kwds)
-
Add a dataset to this system.
Parameters:
name String Variable name of the dataset to be added. DataSet_n for next available integer n. label String Label of the dataset to be added. DataSet_n for next available integer n. Returns:
Returns the handle of the added dataset.
Return type:
DataSet
- export(filename, topology=True, data=True)
-
Exports system to an .mdl file.
Parameters:
filename str Path and name of the .mdl file topology Bool Export topology information. True data Bool Export property data. True Returns:
Returns None.
Return type:
None
- getAttachments(type='')
-
Get a list of all attachment handles of type=type. If type is ‘' then returns all the attachments on this entity.
Parameters:
type str Class name of the type of attachment to be returned. Defaults to Returns:
Returns list of all attachment handles of type=type. If type is ‘' it returns all attachments on this entity.
Return type:
(list)
- getCandidateList(local_only=False, type='')
-
Get a list of all entities with matching candidate tags for every attachment on this system.
Parameters:
local_only Bool Indicates to get only local candidates when True. False type str Class name of the type of attachments that are to be returned. '' Returns:
Returns list of all attachment handles of type=type. If type is ‘' it returns all attachments on this entity.
Return type:
list
- getValue(name)
-
Returns value of an attribute.
Parameters:
name string Name of the attribute. Defaults to . Returns:
The return value. Return type depends on the attribute type.
Return type:
value
- setValue(name, value)
-
Sets value of an attribute.
Parameters:
name str Name of the attribute. value ** Value of the attribute to be set. Returns:
Returns True if the value was successfully set else False.
Return type:
Bool
Examples
========
Create and modify attributes of a System.
>>> from hw import mview
>>> s1 = mview.System(name = 'sys_1',definition_name = "def1")
>>> #Get value of an attribute
>>> s1.definition_name
'def1'
>>> #Set multiple values at once
>>> s1.setValues(use_vx = True, vx = 100)
>>> #Add attachment to the System
>>> s1.addAttachment(name = 'att_point', type = 'Point', value = 'P_Global_Origin', candidate_tag="ap1")
<hw.mview.mbd.System.Attachment object at 0x000001AC54AB8438>
>>> #Add a marker to this system
>>> m1 = mview.Marker(parent = s1)
>>> #Using attachment handle as a reference
>>> m1.origin = s1.att_point
>>> #Create child entity using system variable name
>>> b1 = mview.Body(parent = 'sys_1',usecm = True)
>>> #Using attachment variable name as a reference
>>> b1.cm.origin = "att_point"
>>> #Create a System using definition file
>>> s2 = mview.System(definition_file = "systemexport.mdl", definition_name = "def2")
>>> #Create a body in Model and change its attachment candidate
>>> body1 = mview.Body(name= "body_1")
>>> body1.addAttachmentCandidate(attach_tag="ab")
>>> point1 = mview.Point(name="point_1")
>>> point1.addAttachmentCandidate(attach_tag="ap")
>>> #Add attachments to sys_1 with same candidate tags
>>> s1.addAttachment(name="attPoint", type="Point", candidate_tag="ap")
>>> s1.addAttachment(name="attBody", type="Body", candidate_tag="ab")
>>> #Use getCandidateList to get a list of all matching candidate_tags for each attachment on this system
>>> s1.getCandidateList()
['MODEL.sys_1._attBody_att', 'MODEL.body_1'], ['MODEL.sys_1._attPoint_att', 'MODEL.point_1']]
Attachment
Class Attachment()
class Attachment(parent, name='Attachment_n', label='Attachment_n',
active=True, type='Point', candidate_tag='', value=None)
Creates an attachment on an entity.
Keyword Arguments
Argument | Data Type | Description | Default |
---|---|---|---|
parent | Object | The parent. It is a required parameter. | |
name | String | The variable name. | System_n, for next available integer n. |
label | String | The descriptive label. | System_n, for next available integer n. |
active | Bool | Used to activate or deactivate this entity. | True |
type | String | Class name of the attachment type. | Point |
candidate_tag | String | Candidate tag for this attachment. | ‘' |
value | Reference | Handle of the entity to which this entity is resolved to. | None |
Notes
1. The parent parameter can only be initialized by the constructor and should not be modified directly and is a required parameter.
2. Only parent can be used as a positional argument in the constructor.
Methods
- setValue(name, value)
-
Sets value of an attribute.
Parameters:
name str Name of the attribute. value ** Value of the attribute to be set. Returns:
Returns True if the value was successfully set else False.
Return type:
Bool
Examples
========
Create and modify attachments on different entities.
>>> from hw import mview
>>> s1 = mview.System(name='System_1', label='System_1')
>>> p1 = mview.Point(name='p1')
>>> p2 = mview.Point(name='p2')
>>> #Create an attachment on System_1
>>> a0 = mview.Attachment(parent=s1, name='a0',type='Point', value=p1, candidate_tag='ptag')
>>> #Modify the attachment value
>>> a0.value = p2
>>> #Modify attachment tag
>>> a0.candidate_tag = 'ptag1'
>>> d = mview.DataSet(name = "dataset_1" )
>>> #Add attachments to the dataset using addAttachment function
>>> d.addAttachment(name = "point_attachment", value = p1)
>>> body1 = mview.Body(name='body_1')
>>> #Add multiple attachments using values of those attachments.
>>> #Following command will add attachment of type point with varname point_att and value p1 and
>>> #also attachment of type body with varname body_att and value body1.
>>> d.addAttachment(att_list = {'point_att':p1, 'body_att':body1})
>>> #Using addAttachment for an attachment that already exists will change its value
>>> #Following command will just change the value of attachment a0 on System_1 to p1 from p2
>>> s1.addAttachment(name = 'a0', value = p1 )
Attachment Candidate
Class AttachmentCandidate
AttachmentCandidate(name='AttachmentCandidate_n', label='AttachmentCandidate_n',
active=True, entity=None, attach_tag='')
Tag any entity as a candidate to be used as an attachment when resolving an assembly interactively.
Keyword Arguments
Argument | Data Type | Description | Default |
---|---|---|---|
name | String | The variable name. | AttachmentCandidate_n, for next available integer n. |
label | String | The descriptive label. | AttachmentCandidate_n, for next available integer n. |
active | Bool | Used to activate or deactivate this entity. | True |
entity | Reference | Entity on which this candidate tag is created. | None |
attach_tag | String | The variable name. | System_n, for next available integer n. Defaults to ‘'. |
Boolean Data
Class BooleanData()
class BooleanData(parent, name='BooleanData_n', label='BooleanData_n', active=True, value=False)
Creates a boolean entity.
Keyword Arguments:
Argument | Data Type | Description | Default |
---|---|---|---|
parent | Object | The parent. A required parameter. | |
name | String | The variable name. | BooleanData_n, for next available integer n. |
label | String | The descriptive label. | BooleanData_n, for next available integer n. |
active | Bool | Used to activate or deactivate this entity. | True |
value | Bool | Value of the boolean entity. | False |
Notes
* parent is a required argument.
Examples
========
Create a Boolean data entity and modify its values.
>>> from hw import mview
>>> s1 = mview.System(name="System_1")
>>> s1.addDataSet(name="ds1")
>>> b1 = mview.BooleanData(parent = s1.ds1, name="b1", value= True)
>>> #Create a boolean data in System 1
>>> b2 = mview.BooleanData(parent=s1, name="b2", value=False)
>>> #Modify value of the entity
>>> b2.value = True
>>> #Another way to add boolean data to a dataset or system
>>> ds2 = mview.DataSet(name = 'dataset_2')
>>> s1.dataset_2.addData(type="BooleanData", name="bool_2", value=False)
Integer Data
Class IntegerData()
IntegerData(parent, name='IntegerData_n', label='IntegerData_n', active=True, value=0)
Creates an integer entity.
Keyword Arguments
Argument | Data Type | Description | Default |
---|---|---|---|
parent | Object | The parent. A required parameter. | |
name | String | The variable name. | IntegerData_n, for next available integer n. |
label | String | The descriptive label. | IntegerData_n, for next available integer n. |
active | Bool | Used to activate or deactivate this entity. | True |
value | Int | Value of the integer entity. | 0 |
Notes
* parent is a required argument.
Examples
========
Create an integer data entity and modify its values.
>>> from hw import mview
>>> s1 = mview.System(name="System_1")
>>> s1.addDataSet(name="ds1")
>>> i1 = mview.IntegerData(parent = s1.ds1, name="i1", value=2)
>>> #Create an integer data in System 1
>>> i2 = mview.IntegerData(parent=s1, name="i2", value=3)
>>> #Modify value of the entity
>>> i2.value = 5
>>> #Another way to add integer data to a dataset or system
>>> ds2 = mview.DataSet(name = 'dataset_2')
>>> s1.dataset_2.addData(type="IntegerData", name="r2", value=12)
Option Data
Class OptionData()
OptionData(parent, name='OptionData_n', label='OptionData_n', active=True,
types=['Value 1', 'Value 2'])
Creates an option menu.
Keyword Arguments
Argument | Data Type | Description | Default |
---|---|---|---|
parent | Object | The parent. A required parameter. | |
name | String | The variable name. | OptionData_n, for next available integer n. |
label | String | The descriptive label. | OptionData_n, for next available integer n. |
active | Bool | Used to activate or deactivate this entity. | True |
types | list | Labels for the option menu items. | [‘Value 1', ‘Value 2']. |
value | StringData | Value of the real entity. | 'Value 1'. |
Notes
* parent is a required argument.
Examples
========
Create an option data entity and modify its values.
>>> #Create an option data in dataset1
>>> from hw import mview
>>> s1 = mview.System(name="System_1")
>>> s1.addDataSet(name="ds1")
>>> #Create an option menu with labels for option menus as val1, val2, val3 and val4
>>> od1 = mview.OptionData(parent = s1.ds1, name="od1",types=["val1", "val2", "val3", "val4"],value = "val3")
>>> #Create a string data in System 1
>>> od2 = mview.OptionData(parent=s1, name="od2", types=["Kinetic", "Potential"])
>>> #Modify value of the option menu
>>> od2.value = "Kinetic"
>>> #Another way to add option data to a dataset or system
>>> s1.addDataSet(name="ds1")
>>> s1.ds1.addData(type="OptionData", name="od2", value="Potential")
>>> Change the available menu labels
>>> s1.ds1.od2.types= ["Kin", "Pot"]
Real Data
Class RealData()
RealData(parent, name='RealData_n', label='RealData_n', active=True, value=0.0)
Creates a real entity.
Keyword Arguments
Argument | Data Type | Description | Default |
---|---|---|---|
parent | Object | The parent. A required parameter. | |
name | String | The variable name. | RealData_n, for next available integer n. |
label | String | The descriptive label. | RealData_n, for next available integer n. |
active | Bool | Used to activate or deactivate this entity. | True |
value | Double | Value of the real entity. | 0.0 |
Notes
* parent is a required argument.
Examples
========
Create a real data entity and modify its values.
>>> from hw import mview
>>> s1 = mview.System(name="System_1")
>>> s1.addDataSet(name="ds1")
>>> r1 = mview.RealData(parent = s1.ds1, name="r1", value=2.65)
>>> #Create a real data in System 1
>>> r2 = mview.RealData(parent=s1, name="r2", value=3.65)
>>> #Modify value of the entity
>>> r2.value = 5.87
>>> #Another way to add real data to a dataset or system
>>> ds2 = mview.DataSet(name = 'dataset_2')
>>> s1.dataset_2.addData(type="RealData", name="r2", value=3.96)
String Data
Class StringData()
StringData(parent, name='StringData_n', label='StringData_n', active=True, value='')
Creates a string entity.
Keyword Arguments
Argument | Data Type | Description | Default |
---|---|---|---|
parent | Object | The parent. A required parameter. | |
name | String | The variable name. | StringData_n, for next available integer n. |
label | String | The descriptive label. | StringData_n, for next available integer n. |
active | Boolean | Used to activate or deactivate this entity. | True |
value | StringData | Value of the real entity. | '' |
Notes
* parent is a required argument.
Examples
========
Create a string data entity and modify its values.
>>> from hw import mview
>>> s1 = mview.System(name="System_1")
>>> s1.addDataSet(name="ds1")
>>> string1 = mview.StringData(parent = s1.ds1, name="str1", value="testVal")
>>> #Create an String data in System 1
>>> string2 = mview.StringData(parent=s1, name="str2", value=3)
>>> #Modify value of the entity
>>> string2.value = "modifiedVal"
>>> #Another way to add String data to a dataset or system
>>> ds2 = mview.DataSet(name = 'dataset_2')
>>> s1.dataset_2.addData(type="StringData", name="r2", value="Value 2")
File Name Data
Class FileNameData()
FileNameData(parent, name='OptionData_n', label='OptionData_n', active=True,
ftype='OUTPUT', filter='All files (*.*)|*.*||', value='')
Creates a variable of type FileName.
Keyword Arguments
Argument | Data Type | Description | Default |
---|---|---|---|
parent | Object | The parent. A required argument. | |
name | String | The variable name. | FileNameData_n, for next available integer n. |
label | String | The descriptive label. | FileNameData_n, for next available integer n. |
active | Bool | Used to activate or deactivate this entity. | True |
ftype | list | This argument decides if the browser is used to open a file or save a file. One of (‘INPUT', ‘OUTPUT',‘SINGLE', ‘MULTI'). | 'OUTPUT' |
filter | list | Filter for the file browser. | 'All files' |
value | StringData | File path saved in this data. | '' |
Notes
* parent is a required argument.
Examples
========
Create a filename data and modify its properties.
>>> #Create filename data in dataset1
>>> from hw import mview
>>> s1 = mview.System(name="System_1")
>>> s1.addDataSet(name="ds1")
>>> #Create a filename data to save a file.
>>> fd1 = mview.FileNameData(parent = s1.ds1, name="fd1", filter="*.txt", ftype="OUTPUT",value="C:/example.txt")
>>> #Change the file type
>>> fd1.ftype = "INPUT"
>>> #Change the filter
>>> fd1.filter = "*.mdl"