I want to create an API with vb.net.
Is there a way to connect vb.net to the Moldflow synergy API?
If so, please give me a simple sample code.
Hi,
first, I have not used vb.net for Moldflow API, so not a clear cut answer .
Generally, you need to connect to Moldflow Synergy by OLE.
This is what it looks like for VBS/VBA:
SetLocale("en-us")
Dim SynergyGetter, Synergy
On Error Resume Next
Set SynergyGetter = GetObject(CreateObject("WScript.Shell").ExpandEnvironmentStrings("%SAInstance%"))
On Error GoTo 0
If (Not IsEmpty(SynergyGetter)) Then
Set Synergy = SynergyGetter.GetSASynergy
Else
Set Synergy = CreateObject("synergy.Synergy")
End If
Maybe you have other examples of how to connect to an application in vb.net, that could be used to adapt the vbs code?
Hope this helps somewhat.
Regards,
Berndt
Hi,
Thank you for your help.
I want to use vb.net because I am used to it.
I'm going to make a simple example.
However, I would like to ask for help because there is a problem.
It's possible through vbs, but an error occurs in vb.net.
I want to know what the problem is.
To create a simple line, I was using the example code below
vbs Code:
'%RunPerInstance
'@ DESCRIPTION
'@ Macro recorded by Synergy on 03-9-2020 at 14:23:08
SetLocale("en-us")
Dim SynergyGetter, Synergy
On Error Resume Next
Set SynergyGetter = GetObject(CreateObject("WScript.Shell").ExpandEnvironmentStrings("%SAInstance%"))
On Error GoTo 0
If (Not IsEmpty(SynergyGetter)) Then
Set Synergy = SynergyGetter.GetSASynergy
Else
Set Synergy = CreateObject("synergy.Synergy")
End If
Synergy.SetUnits "Metric"
Set Vector = Synergy.CreateVector()
Set Vector_1 = Synergy.CreateVector()
Set Modeler = Synergy.Modeler()
Modeler.FindProperty 0, 0
Vector.SetXYZ 56.5, -51.15, -2.5
Vector_1.SetXYZ 0, 4, 0
Set EntList = Modeler.CreateLine(Vector, Vector_1, True, Nothing, False)
vb.net Code :
Public Class Form1
Private MFA As Object
Private MFAProject As Object
Private MFADoc As Object
Private oModeler As Object
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MFA = CreateObject("synergy.synergy")
Dim Vector = MFA.CreateVector()
Dim Vector_1 = MFA.CreateVector()
oModeler = MFA.Modeler()
oModeler.FindProperty(0, 0)
Vector.SetXYZ(0, 0, 0)
Vector_1.SetXYZ(100, 200, 0)
Dim EntList = oModeler.CreateLine(Vector, Vector_1, False, Nothing, True) ----> Error
End Sub
End
Thanks,
Sung-Jun Lee
Hi Sung-Jun Lee,
what happens if you remove "Dim" before as such:
EntList = oModeler.CreateLine(Vector, Vector_1, False, Nothing, True)
Regards,
Berndt
Hi, Berndt
When I removed "Dim" before as such, The result is the same.
I've tried a few other ways, but it is same.
Thanks,
Sung-Jun Lee
Hi Sung-Jun Lee,
thank you for the feedback.
Right, I understand.
I am using vbs/vba for macros and scripts, and have not used vb.net .
So do not have any resolution to the issue.
Hope someone in community could help and shed some light over this.
Regards,
Berndt
Brian, I am just starting to code with Moldflow using VB.Net. Would you have an example program to share.
Little stuck getting going.
Thanks
Rob
Can't find what you're looking for? Ask the community or share your knowledge.