Delphi - OleVariant from AddRegion

Discussion in 'AutoCAD' started by Jack Houben, Jun 25, 2004.

  1. Jack Houben

    Jack Houben Guest

    Hello all,

    I have a rectangle with fillets.
    First I put it in an array and use the array to create a region with
    AddRegion.
    AddRegion returns an OleVariant. The code compiles ok, byut at runtime I get
    an EOleError: Variant doe not reference an automation object.
    When I try ReturnObj as AcadRegion there is a type mismatch: Incompatible
    types: 'OleVariant' and 'IAcadRegion'

    Wats the correct approach for this? See code below...

    ReturnObj: OleVariant;
    Outside: OleVariant;
    Inside: OleVariant;
    Result: OleVariant;

    RectArray:=VarArrayCreate([0,0],varDispatch);
    ....
    -> draw a rounded rectangle
    ....
    // put entlast in the array
    RectArray[0] := MSpace.Item(MSpace.Count-1);
    ReturnObj:=MSpace.AddRegion(RectArray); <-- Incompatible type when using
    AcadRegion
    OutSide:=ReturnObj;
    ....
    -> the same again for another, smaller rectangle
    ....
    InSide:=ReturnObj;
    ....
    // subtract Inside from Outside
    Result:=Outside.Boolean(acSubtraction,Inside); <-- EOleError when using
    OleVariants


    Thanks in advance,
    Jack
     
    Jack Houben, Jun 25, 2004
    #1
  2. When a variant array of AutoCAD entities is
    the result, you can get an element from it
    like this:

    var
    Region: AcadRegion;

    ResultArray: OleVariant;

    begin

    ResultArray := MSpace.AddRegion(...);

    Region := IDispatch(ResultArray[0]) As AcadRegion;





    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning
     
    Tony Tanzillo, Jun 25, 2004
    #2
  3. Jack Houben

    Jack Houben Guest

    Thanks Tony,

    Works fine!


    Jack

     
    Jack Houben, Jun 26, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.