SetAttachment - MapleSim Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : MapleSim : MapleSim Application Programming Interface : API Commands : MapleSim/LinkModel/SetAttachment

SetAttachment

set the attachment (text, Maple structures, files) to the linked MapleSim model

 Calling Sequence A := MapleSim:-LinkModel(); A:-SetAttachment(name, content, options)

Parameters

 name - string ; name of the attachment content - anything ; content of the attachment options - (optional) equation(s) of the form name = value

Returns

 • none

Options

 • category : one of the following: "custom", "datasets", "cad", "other", "documents"
 Specifies the category where the attachment should be placed. Default is "documents".
 • filecopy : true or false
 If set to true, the content parameter is assumed to be a name of the file to be attached to the active model. Default is false.

Description

 • A:-SetAttachment sets the attachment to a linked model A.
 • The A := MapleSim:-LinkModel() statement needs to be run prior to successfully using any of the ModelObject A's export functions.

Examples

Linking to a MapleSim model (located in .msim file):

 > $A≔\mathrm{MapleSim}:-\mathrm{LinkModel}\left('\mathrm{filename}'=\mathrm{cat}\left(\mathrm{kernelopts}\left('\mathrm{toolboxdir}'=\mathrm{MapleSim}\right),"/data/examples/RLCcircuit.msim"\right)\right):$

Setting the attachment (text) to the linked MapleSim Model:

 > $\mathrm{data}≔"this will be the ship"$
 ${\mathrm{data}}{≔}{"this will be the ship"}$ (1)
 > $A:-\mathrm{SetAttachment}\left("data.txt",\mathrm{data},'\mathrm{category}'="other"\right)$

Setting the attachment (a list) to the linked MapleSim Model:

 > $L≔\left[1,2,3,4\right]:$
 > $A:-\mathrm{SetAttachment}\left("data.csv",L,'\mathrm{category}'="datasets"\right)$

Getting the data from the attachment:

 > $A:-\mathrm{GetAttachment}\left("data.csv"\right)$
 $\left[\begin{array}{cccc}{1.}& {2.}& {3.}& {4.}\end{array}\right]$ (2)

Listing the attachments of the linked MapleSim Model:

 > $A:-\mathrm{ListAttachments}\left(\right)$
 $\left[{"data.txt"}{,}{"data.csv"}\right]$ (3)
 > $A:-\mathrm{ListAttachments}\left(\mathrm{showcategories}=\mathrm{true}\right)$
 $\left[\left[{"data.txt"}{,}{"other"}\right]{,}\left[{"data.csv"}{,}{"datasets"}\right]\right]$ (4)

Setting the attachment (a file) to the linked MapleSim Model:

 > $\mathrm{fd}≔\mathrm{FileTools}:-\mathrm{Text}:-\mathrm{Open}\left("samplefile.txt",\mathrm{create}=\mathrm{true},\mathrm{overwrite}=\mathrm{true}\right):$
 > $\mathrm{FileTools}:-\mathrm{Text}:-\mathrm{WriteString}\left(\mathrm{fd},"This is a test file."\right):$
 > $\mathrm{FileTools}:-\mathrm{Text}:-\mathrm{Close}\left(\mathrm{fd}\right):$
 > $A:-\mathrm{SetAttachment}\left("sampleAttachedFile.txt",\mathrm{cat}\left(\mathrm{currentdir}\left(\right),"/samplefile.txt"\right),\mathrm{filecopy}=\mathrm{true}\right):$

Listing the attachments of the linked MapleSim Model:

 > $A:-\mathrm{ListAttachments}\left(\right)$
 $\left[{"data.txt"}{,}{"data.csv"}{,}{"sampleAttachedFile.txt"}\right]$ (5)

 See Also

Was this information helpful?

 Please add your Comment (Optional) E-mail Address (Optional) What is ? This question helps us to combat spam