AutoCAD 2004/2002 and AcadBlockReference

Discussion in 'AutoCAD' started by nik_s, Feb 3, 2004.

  1. nik_s

    nik_s Guest

    I have created 2 TLBs one for AutoCAD2002 another for 2004, and change Delphi code to support both versions, everything works fine except when i'm using AcadBlockReference, I have something like this:

    function foo()
    var
    ...
    blockRefObj,
    currDwg :IDispatch;
    varAttributes : OleVariant;
    begin
    ....
    if AutoCAD2004 then
    begin
    blockRefObj := (currDwg as INAcadDocument).ModelSpace.InsertBlock(varInsPoint, sblkName,sXScale,sXScale,sXScale,0.0, EmptyParam);
    end else//The block exists so just update the attributes
    blockRefObj := varSelSet.Item(0);
    varAttributes := (blockrefObj as INAcadBlockReference).GetAttributes;
    end else
    begin
    blockRefObj := (currDwg as IOAcadDocument).ModelSpace.InsertBlock(varInsPoint, sblkName,sXScale,sXScale,sXScale,0.0);
    end else//The block exists so just update the attributes
    blockRefObj := varSelSet.Item(0);
    varAttributes := (blockrefObj as IOAcadBlockReference).GetAttributes;
    end;
    //then try this
    for indx := 0 to cdsAcad.RecordCount -1 do
    begin
    varAttributes[ictr].textString := cdsAcadt.FieldByName('n1').text;
    varAttributes[ictr+1].textString := cdsAcadt.FieldByName('n2').text;
    varAttributes[ictr+2].textString := cdsAcadt.FieldByName('n3').text;
    cdsAcadCompliment.Next;
    iCtr := iCtr +3;
    ....
    end;

    It works fine with AutoCAD2002 but get error when using 2004 "Library not register: in line
    varAttributes[ictr].textString := cdsAcadt.FieldByName('n1').text;
    I did try some type casting as INAcadAttributeDisp but wouldn't compile
    anybody experiencing something similar

    thanks in advance!
     
    nik_s, Feb 3, 2004
    #1
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.