COMSOL VBA

kato01

Full Member level 2
Joined
Dec 2, 2002
Messages
127
Helped
6
Reputation
12
Reaction score
3
Trophy points
1,298
Visit site
Activity points
846
I am tring to build a COMSOL project file from EXCEL using the COMSOL excel addon.
My code shown below fails on the "GEO Line.

I get this error:
"wrong number of arguments or invalid property assignment"

Anybody can help?
Thank you



Code Visual Basic - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Sub comsol_vbs_test()
Set comsolutil = CreateObject("comsolcom.comsolutil")
Set modelutil = CreateObject("comsolcom.modelutil")
Call comsolutil.TimeOutHandler(True)
Call comsolutil.StartComsolServer(True)
Call modelutil.Connect
Set modelutil = CreateObject("ComsolCom.ModelUtil")
Dim model As ModelImpl
Set model = modelutil.Create("Model")
Call model.modelPath("G:\MyDocuments\comsol\PROJECTS")
Call model.Comments("Untitled" & vbNewLine & "" & vbNewLine & "")
Call model.ModelNode().Create("comp1")
Call model.geom().Create("geom1", 2)
Call model.get_geom("geom1").axisymmetric(True)
Call model.mesh().Create("mesh1", "geom1")
Call model.physics().Create("emw", "ElectromagneticWaves", "geom1")
Call model.study().Create("std1")
Call model.get_study("std1").Create("freq", "Frequency")
Call model.get_study("std1").get_feature("freq").Activate("emw", True)
Call model.get_component("comp1").geom("geom1").Create("c1", "Circle")
 
Call comsol_server_disconnect
 
End Sub
Sub comsol_server_disconnect()
Set comsolutil = CreateObject("comsolcom.comsolutil")
Set modelutil = CreateObject("comsolcom.modelutil")
Call comsolutil.TimeOutHandler(True)
Call modelutil.Disconnect
End Sub

 

My code shown below fails on the "GEO Line.
What is the GEO line? Wouldn´t it be a good idea to use line numbers?
Why not showing the full error message?

Did you read the documentation?

If you want us to read the documentation (after you did) --> post a link to the documentation.

Klaus
 


Hi,

Why do you write "geo" when it is "geom"?
And "geo" is 8 times in your code...

*****
Now back to the documentation:
Where in this document does it describe/explain the syntax you used?
--> Please give the page number.

*****
I still doubt you showed the full error message.
--> Please shof the full error message.

Klaus
 

Klaus,

Apparently you are not familiar with the topic.
I would need answers from somebody who is.
Your suggestions are not helping.
 

Hi,

You are right. I´m not familiar with the topic. But I´m able to read datasheets.. and did a lot of VB and VBA applications in the past.
You sent the documentation. It took me about 10 seconds to find at least two issues (or two possible solutions) with your code.

You don´t call it helping. Fair enough.

But if I immediately tell you what I found out ... I still needed your confirmation. .. while you had not learned anything. Nothing you can use in the future.

But my intention is not to "rectify the issue for you" as fast as possible .... but to help you not to make similar mistakes again and again. I try to give you a benefit for life, not for a short moment.

I see my way more like a tennis trainer. I will not take your racket and play and run for you. But I can show you how to play good tennis in your own.
In best case you later play better tennis than me and make more money than me.

But tennis player and trainer need to "match" somehow. The player needs to trust the trainer .. and usually the player needs to follow the trainer´s recommendations, and the player needs to do the workout and training - not the trainer. The hard work is on the player´s side.
There´s nothing wrong when you say I´m not a suitable trainer for you.

Klaus
 

Cookies are required to use this site. You must accept them to continue using the site. Learn more…