Sign in to follow this  
Followers 0
JustinMeyer

Object - Converting C# to AU3

8 posts in this topic

#1 ·  Posted (edited)

Thanks for looking, any insight or suggestions are greatly appreciated!

I have been trying to find the solution for 3 days and can not get it... so now I ask the proffessionals.

I am new to objects but have been using Tekla Structures (3D Structural modeling software) for years. With

the code below I am able to connect to the process fine, and in other scripts can pull or return information

from the model. The problem comes when I try to send information to Tekla. I will explain some of the results

after the code.

#Region
$TSMm = ObjCreate("Tekla.Structures.Model.Model")
$TSMgeoP = ObjCreate("Tekla.Structures.Geometry3d.Point")
$TSMgeoP2 = ObjCreate("Tekla.Structures.Geometry3d.Point")
$TSMuiGD = ObjCreate("Tekla.Structures.Model.UI.GraphicsDrawer")
$TSMuiP = ObjCreate("Tekla.Structures.Model.UI.Picker")
$TSMuiColor = ObjCreate("Tekla.Structures.Model.UI.Color")
#EndRegion
;$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

;The following line requests that you pick a point in the model
;The variable returns X ($IntPnt.X) Y and Z
$IntPnt = $TSMuiP.PickPoint()

$String = "X = " & $IntPnt.X & " " & "Y = " & $IntPnt.Y & " " & "Z = " & $IntPnt.Z
$Color = $TSMuiColor();black

;This line should draw $String to the active model view at the picked point
$TSMuiGD.DrawText($IntPnt, $String, $Color)

Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Windescription is: " & $oMyError.windescription & @CRLF & _
                "Source is: " & $oMyError.source & @CRLF & _
                "Description is: " & $oMyError.description & @CRLF & _
                "Helpfile is: " & $oMyError.helpfile & @CRLF & _
                "Helpcontext is: " & $oMyError.helpcontext & @CRLF & _
                "Lastdllerror is: " & $oMyError.lastdllerror & @CRLF & _
                "Scriptline is: " & $oMyError.scriptline)

   $g_eventerror = 1 
Endfunc

I know the code is a big mess but I am just trying to get it working before I create anyhting I will share.

When I have the object error handler commented out, I get this output in scite:

Connecting to Tekla Structures process...

Connection succeeded

C:\Documents and Settings\jmeyer\Desktop\Tekla\Tekla Obj DrawText.au3 (18) : ==> The requested action with this object has failed.:

$TSMuiGD.DrawText($IntPnt, $String, $Color)

$TSMuiGD.DrawText($IntPnt, $String, $Color)^ ERROR

>Exit code: 1 Time: 3.485

With the error handler on it returns 80070057 as the number and "The parameter is incorrect." for the Windescription

This is the code in the tekla help file:

public bool DrawText(
   Point Location,
   String Text,
   Color Color
);

And an example of usage:

drawer.DrawText(new Point(0.0, 1000.0, 1000.0), "TEXT SAMPLE", new Color(1.0, 0.5, 0.0))

The example below was done by someone that uses C#, and it works. IntPnt is the variable that returns from pick point.

TSM.UI.Color Color = new TSM.UI.Color();

TSM.UI.GraphicsDrawer Drawer = new Tekla.Structures.Model.UI.GraphicsDrawer();
Drawer.DrawText(IntPnt, "Text Sample", Color);

If you need more specific information to help me out just ask.

Thanks again!

Edited by JustinMeyer

Share this post


Link to post
Share on other sites



You might want to say that you're trying to convert C# to AutoIt, instead of C. Now you're attracting the wrong kind of professionals (those that know C), which is on a whole other level.

Share this post


Link to post
Share on other sites

You might want to say that you're trying to convert C# to AutoIt, instead of C. Now you're attracting the wrong kind of professionals (those that know C), which is on a whole other level.

Thanks, fixed.


Share this post


Link to post
Share on other sites

Have you tried to change:

$Color = $TSMuiColor()

to

$Color = $TSMuiColor(1.0, 0.5, 0.0)

Share this post


Link to post
Share on other sites

Have you tried to change:

$Color = $TSMuiColor()

to

$Color = $TSMuiColor(1.0, 0.5, 0.0)

I have, however by not defining the RGB it defaults to black. And that is not a problem.

I am having problems passing the point ($IntPnt) XYZ back to tekla. I have no experience with C#, and this

is the first for me with objects. I am thinking that autoit may handle the ?array? $IntPnt differently than

Tekla expects. It is (sort of) an array, I think. $IntPnt.X $IntPnt.Y and $IntPnt.Z all hold vallues.


Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I have, however by not defining the RGB it defaults to black. And that is not a problem.

I am having problems passing the point ($IntPnt) XYZ back to tekla. I have no experience with C#, and this

is the first for me with objects. I am thinking that autoit may handle the ?array? $IntPnt differently than

Tekla expects. It is (sort of) an array, I think. $IntPnt.X $IntPnt.Y and $IntPnt.Z all hold vallues.

No idea what the problem is here, but I just wanted to point out that $IntPnt holds an object or struct of type Point, not an array, where X and Y and Z are properties (of type double probably). Edited by Manadar

Share this post


Link to post
Share on other sites

No idea what the problem is here, but I just wanted to point out that $IntPnt holds an object or struct of type Point, not an array, where X and Y and Z are properties (of type double probably).

Thank you for clearing that up Manadar, and you are correct that $IntPnt.X, $IntPnt.Y and $IntPnt.Z are each double.


Share this post


Link to post
Share on other sites

I have been trying ways of getting this to work with no solution.

I have been testing with different types of objects and have come to the conclusion that I am able to request information form the (Tekla) model and or have the user perform an action that returns information. I can not send any data to the model (Tekla Object) though. I would love to solve this. I am open to any suggestions or known issues.

Thanks


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0