AutoCAD Mechanical General Discussion

AutoCAD Mechanical General Discussion

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

Possible Ge.Application bug in Mechanical 2005

79 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 (79 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.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.