Message 1 of 6
Delphi - OleVariant a pointer in D6?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All,
I create 2 spheres and then move the second until there is no more interference between the two. Keeping track of the new coordintes.
following code works fine in Delphi 5:
procedure TForm1.Button1Click(Sender: TObject);
var
AcadApp: AcadApplication;
Drawing: AcadDocument;
MSpace : AcadModelSpace;
p1 : OleVariant;
p2 : OleVariant;
Sphere1 : Acad3DSOlid;
Sphere2 : Acad3DSolid;
Intersection : Acad3DSOlid;
Interference : Boolean;
begin
AcadApp := GetAcadApplication(True);
MSpace := AcadApp.ActiveDocument.ModelSpace;
// Create point arrays
p1 := VarArrayCreate([0,2], varDouble);
p2 := VarArrayCreate([0,2], varDouble);
// assign values to points
p1[0] := 0.0; p1[1] := 0.0; p1[2] := 0.0;
p2 := p1;
// Create 3DSolid opbjects
Sphere1 := MSpace.AddSphere(p1,5);
Sphere2 := MSpace.AddSphere(p2,5);
Interference:=True;
// Move Sphere2 until there is no interference
while Interference do
begin
Intersection:=Sphere1.CheckInterference(Sphere2,true);
if Intersection=nil then
Interference:=false
else
begin
// Delete created intersection
Intersection.Delete;
// Intersection:=nil;
p1:=p2;
// Calculate new coordinates for Sphere2
p2[0]:=p2[0]+0.1;
p2[1]:=p2[1]+0.1;
p2[2]:=p2[2]+0.1;
// Move Sphere2
Sphere2.Move(p1,p2);
Sphere2.Update;
p1:=p2;
end;
end;
end;
In Delphi 6 however, a change to p1 or p2 has the same effect on the other.
Is D5 behaviour correct or is D6?
Are there samples of AcadX use in Delphi? The links to samples in the "What's New" section on Tony's site seem to be broken...
Thanks,
Jack
I create 2 spheres and then move the second until there is no more interference between the two. Keeping track of the new coordintes.
following code works fine in Delphi 5:
procedure TForm1.Button1Click(Sender: TObject);
var
AcadApp: AcadApplication;
Drawing: AcadDocument;
MSpace : AcadModelSpace;
p1 : OleVariant;
p2 : OleVariant;
Sphere1 : Acad3DSOlid;
Sphere2 : Acad3DSolid;
Intersection : Acad3DSOlid;
Interference : Boolean;
begin
AcadApp := GetAcadApplication(True);
MSpace := AcadApp.ActiveDocument.ModelSpace;
// Create point arrays
p1 := VarArrayCreate([0,2], varDouble);
p2 := VarArrayCreate([0,2], varDouble);
// assign values to points
p1[0] := 0.0; p1[1] := 0.0; p1[2] := 0.0;
p2 := p1;
// Create 3DSolid opbjects
Sphere1 := MSpace.AddSphere(p1,5);
Sphere2 := MSpace.AddSphere(p2,5);
Interference:=True;
// Move Sphere2 until there is no interference
while Interference do
begin
Intersection:=Sphere1.CheckInterference(Sphere2,true);
if Intersection=nil then
Interference:=false
else
begin
// Delete created intersection
Intersection.Delete;
// Intersection:=nil;
p1:=p2;
// Calculate new coordinates for Sphere2
p2[0]:=p2[0]+0.1;
p2[1]:=p2[1]+0.1;
p2[2]:=p2[2]+0.1;
// Move Sphere2
Sphere2.Move(p1,p2);
Sphere2.Update;
p1:=p2;
end;
end;
end;
In Delphi 6 however, a change to p1 or p2 has the same effect on the other.
Is D5 behaviour correct or is D6?
Are there samples of AcadX use in Delphi? The links to samples in the "What's New" section on Tony's site seem to be broken...
Thanks,
Jack