Thema: Delphi Problem mit Variant

Einzelnen Beitrag anzeigen

ede57

Registriert seit: 5. Apr 2008
Ort: Hamburg
46 Beiträge
 
Delphi XE Professional
 
#20

Re: Problem mit Variant

  Alt 12. Nov 2008, 12:53
Habe alles gegeben
Habe ein Testproject mit C++ Builder 2007 erstellt
----- C++ Code

Variant CatApp;
Variant CatDocList;
Variant CatDoc;
Variant CatDocPart;
Variant CatDocBodies;
Variant CatBodiesBody;
Variant CatBodieShapes;
Variant CatShape;
Variant ShapePoints;
double points[3];
int bounds[2] = {0,2};
unsigned short vx;
String name;
//---------------------------------------------------------
CatApp = GetActiveOleObject("Catia.Application");
CatDocList = CatApp.OlePropertyGet("Documents");
CatDoc = CatDocList.OleFunction("Item",1);
CatDocPart = CatDoc.OlePropertyGet("Part");
CatDocBodies = CatDocPart.OlePropertyGet("Bodies");
CatBodiesBody = CatDocBodies.OleFunction("Item",1);
CatBodieShapes = CatBodiesBody.OlePropertyGet("Shapes");
CatShape = CatBodieShapes.OleFunction("Item",3);
name = CatShape.OlePropertyGet("Name");
Memo1->Lines->Add(name); // its OK
ShapePoints = VarArrayCreate(bounds,1,varVariant);
// SafeArrayRedim(*ShapePoints.VArray,AB);
vx == TVarData(ShapePoints).VType; // its 0x200C
CatShape.OleFunction("getOrigin",ShapePoints);
vx == TVarData(ShapePoints).VType; // its 0x200C
points[0] = ShapePoints.GetElement(0);
Memo1->Lines->Add(FloatToStr(points[0])); // its 0 not 185
----------------------------

Keinen Erfolg

Dann habe ich jetzt das testproject mal mit Visaul Basic 2008 erstellt
----------VB Code
Private Testprocedure
Dim CatApp As Object
Dim catDocs As Object
Dim CatDoc As Object
Dim CatPart As Object
Dim CatBodies As Object
Dim CatBody As Object
Dim CatbodyShapes As Object
Dim CatShape As Object
Dim name As String
Dim BPoints(3) As Object
;-----------------------------------------
CatApp = CreateObject("Catia.Application")
catDocs = CatApp.Documents
CatDoc = catDocs.Item(1)
CatPart = CatDoc.Part
CatBodies = CatPart.Bodies
CatBody = CatBodies.Item(1)
CatbodyShapes = CatBody.Shapes
CatShape = CatbodyShapes.Item(3)
name = CatShape.name
ListBox1.Items.Add(name)
CatShape.GetOrigin(BPoints)
ListBox1.Items.Add(FormatNumber(BPoints(0)))
ListBox1.Items.Add(FormatNumber(BPoints(1)))
ListBox1.Items.Add(FormatNumber(BPoints(2)))
End Sub
----------VB Code
Kann alle Werte Ohne Probleme auslesen
Warum nicht mit Delphi 2007 oder C++ Builder 2007
  Mit Zitat antworten Zitat