cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

generating Mathcad XML-Code

ArneClaußen
1-Newbie

generating Mathcad XML-Code

Hey Guys,

for my calculations i use c.a. 4 pages with variables. In my calculation-sheet i use a reference link to the mathcad-file (with the variables)

My dream is that i have an excel file with the variables. From there i want to use a vba script to generate the xml code in order to use the variables as an mathcad-file.

First of all: Do you understand what i mean?

second: As someone done something like this before?

Has someone an overview for the xml syntax?

Greetings

4 REPLIES 4
MikeArmstrong
5-Regular Member
(To:ArneClaußen)

I think I understand. You want to use an Excel worksheet as a master input sheet and called the variables into Mathcad?


If so, this can be done no problem.


Mike

I would create a Mathcad file with a few variable definitions in it and nothing else. Then you should be able to figure out what the XML looks like for the definitions. There will be a chunk of XML before the first definition, and a chunk after the last one, Call these the "header" and the "footer". You could copy these to text files to store them. Then the Excel sheet copies the header into the new file, writes some variable definitions, copies the footer, then saves the file. As long as the header or footer do not contain information about the number of variable definitions I think this should work.

Hello,

I hoped to find a How-To or something similar, but now i did what you suggested.

open a xmcd-file with the windows notepad.

I found out, that the variables are defined in regions and one variable is one region.

Like this:

<regions>
<region region-id="3" left="0" top="-9" width="35.25" height="12.75" align-x="23.25" align-y="0" show-border="false" show-highlight="false" is-protected="true" z-order="0" background-color="inherit" tag="">
<math optimize="false" disable-calc="false">
<ml:define xmlns:ml="http://schemas.mathsoft.com/math30">

<ml:id xml:space="preserve">arne</ml:id>

<ml:real>1</ml:real>
</ml:define>
</math>
<rendering item-idref="1"/>
</region>

</regions>

the red-bold "arne" is the name of the variable and the red-bold "1" is the value.

i just have to change the place of the variables with left and top.

Greetings,

I try to create a region L_value by script inside a textbox, i built XML for that region, it's something wrong in my script but i can not figure out how to fix it, plz help me.

Option Explicit

Sub TextBoxEvent_Start()

Rem TODO: Add your code here

End Sub

Sub TextBoxEvent_Exec(Inputs,Outputs)

Dim XML, Reg

For Each Reg in WorkSheet.Regions

If Reg.Tag = "L_value" Then

TextBox.Text = Reg.Tag

XML = "<ml:define xmlns:ml=""http://schemas.mathsoft.com/math30"">"

XML = XML & vbCrLf & "<ml:id xml:Space=""preserve"">b</ml:id>"

XML = XML & vbCrLf & "<ml:real>1</ml:real>"

XML = XML & vbCrLf & "</ml:define>"

Reg.MathInterface.XML = XML

Exit For

End If

Next

End Sub

Sub TextBoxEvent_Stop()

Rem TODO: Add your code here

End Sub

Top Tags