AutoCAD Mechanical General Discussion

Reply
Contributor
dhaverstick
Posts: 22
Registered: ‎01-12-2004
Message 1 of 2 (75 Views)

Possible Ge.Application bug in Mechanical 2005

75 Views, 1 Replies
10-06-2004 05:54 AM
Can anyone duplicate this behavior in Autocad Mechanical 2005 VBA/VB?

Sub test()
Dim GEAPP As GeApplication
Dim Point1 As GePoint
Dim Point2 As GePoint
Dim Var1 As Double

Set GEAPP = ThisDrawing.Application.GetInterfaceObject("Ge.Application")
Set Point1 = GEAPP.Point(0, 0, 0)
Set Point2 = Point1
Point2.X = 1: Point2.Y = 3
Var1 = Point1.X 'Point1.X value takes on the value of Point2.X - This should not happen
Var1 = Point1.Y 'Point1.Y value takes on the value of Point2.Y - This should not happen
End Sub

In my programming experience, setting Point2 = Point1 does not mean the same thing as setting Point1 = Point2. However, in my example, this is what is happening. If you can reproduce this behavior then this DLL has a HUUUUUGE problem.
*Robert McMillan \(Autodesk\)
Message 2 of 2 (75 Views)

Re: Possible Ge.Application bug in Mechanical 2005

10-06-2004 10:16 AM in reply to: dhaverstick
Darren, this is the correct behavior because GePoint and most other API objects for AutoCad, GeAuto, and McadAuto are VBA Objects, and the variables that refer to objects are like pointers in C++. Here is the definition for the Set statement from the VBA help: "Assigns an object reference to a variable or property." Another word for "reference" in this context is "pointer". There is only one GePoint object in your sample code, and there are two variables pointing to it. You would need to construct another GePoint object for Point2 and then you could say, Point2 = Point1.asArray Which will set the xyz values in Point2 to match Point1. -- Robert McMillan Software Developer MDT & AutoCAD Mechanical team "dhaverstick" wrote in message news:11386079.1097067297230.JavaMail.jive@jiveforum1.autodesk.com... > Can anyone duplicate this behavior in Autocad Mechanical 2005 VBA/VB? > > Sub test() > Dim GEAPP As GeApplication > Dim Point1 As GePoint > Dim Point2 As GePoint > Dim Var1 As Double > > Set GEAPP = ThisDrawing.Application.GetInterfaceObject("Ge.Application") > Set Point1 = GEAPP.Point(0, 0, 0) > Set Point2 = Point1 > Point2.X = 1: Point2.Y = 3 > Var1 = Point1.X 'Point1.X value takes on the value of Point2.X - This should not happen > Var1 = Point1.Y 'Point1.Y value takes on the value of Point2.Y - This should not happen > End Sub > > In my programming experience, setting Point2 = Point1 does not mean the same thing as setting Point1 = Point2. However, in my example, this is what is happening. If you can reproduce this behavior then this DLL has a HUUUUUGE problem.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community