Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X
Hi All,
I have a problem with the scriptable drop-down menu object.
If I select a value from the list, and then save the model, the set value will be forgotten by Mathcad upon opening again. And the default value (first one) is set again.
Can this behavior by any method be changed?
Thanks,
Zsolt
Solved! Go to Solution.
The attached should do what you want. Just change the display options.
The attached should do what you want. Just change the display options.
Wow, thanks, this one works.
Though I have to dug into the script a little bit, as it assigns an incremental value of 1-2-3-4... to the variable, while I want to assign exact values corresponding to bar diameters.
Do you have a solution for the tick-mark (yes/no) object too?
Zsolt Roman wrote:
Wow, thanks, this one works.
Though I have to dug into the script a little bit, as it assigns an incremental value of 1-2-3-4... to the variable, while I want to assign exact values corresponding to bar diameters.
Do you have a solution for the tick-mark (yes/no) object too?
I don't, but do know where you can find one . Curiosity of Richard.
This is also very good, thank you.
I attached my modified version, where different values can be assigned to the variable. (instead of 1-2-3...)
The modified (still savebale) script:
______________________________________________
Dim OnLoad:OnLoad=1
'Define a metadata object
Set myMetadata = CreateObject("Mathcad.CustomMetadataItem")
'Set Type of the Metadata
myMetadata.Type = mcCMTText
Rem Initialize List Box
ListBox.ResetContent()
Rem Add Strings here as needed
ListBox.AddString("24f-E (DF Only)")
ListBox.AddString("24f_Ex(DF Only)")
ListBox.AddString("20f-E")
ListBox.AddString("20f-Ex")
ListBox.AddString("18t-E (DF) / 14t-E (SPF)")
ListBox.AddString("16c-E (DF) / 12c-E (SPF)")
Sub ListBoxEvent_Start()
End Sub
Sub ListBoxEvent_Exec(Inputs,Outputs)
ListBoxName=Inputs(0).Value
If OnLoad=1 Then
Rem Initialize Selection If desired
ListBox.CurSel = 0
Set metadata = worksheet.metadata 'Interface
Set items = metadata.customitems 'collection of custom properties
For each item in items
If (item.name = ListBoxName) Then
ListBox.CurSel = item.value
End If
Next
OnLoad=0
End If
'Update the metadata
myMetadata.Name = ListBoxName
myMetadata.Value = ListBox.CurSel
Worksheet.Metadata.AddCustomItem myMetadata
sel = ListBox.CurSel
If sel = 0 Then
Outputs(0).Value = 9.525
End If
If sel = 1 Then
Outputs(0).Value = 12.7
End If
If sel = 2 Then
Outputs(0).Value = 15.875
End If
If sel = 3 Then
Outputs(0).Value = 19.05
End If
If sel = 4 Then
Outputs(0).Value = 22.225
End If
If sel = 5 Then
Outputs(0).Value = 25.4
End If
End Sub
Sub ListBoxEvent_Stop()
End Sub
Sub ListBox_SelChanged()
ListBox.Recalculate()
End Sub
Sub ListBox_DblClick()
ListBox.Recalculate()
End Sub
______________________________________________