AutoCAD Mechanical Forum
Welcome to Autodesk’s AutoCAD Mechanical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Mechanical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Possible Ge.Application bug in Mechanical 2005

1 REPLY 1
Reply
Message 1 of 2
dhaverstick
200 Views, 1 Reply

Possible Ge.Application bug in Mechanical 2005

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.
1 REPLY 1
Message 2 of 2
Anonymous
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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost