Results 1 to 2 of 2

Thread: why does this line of code work?

  1. #1
    Member
    Join Date
    2006-06
    Posts
    18
    Login to Give a bone
    0

    Default why does this line of code work?

    can someone help me? why does this line of code work?

    AcDbObjectId lineId = AcDbObjectId::kNull;
    pBlockTableRecord->appendAcDbEntity(lineId, pLine);

    shouldn't it be this....


    AcDbObjectId *lineId = new AcDbObjectid();
    pBlockTableRecord->appendAcDbEntity(lineId, pLine);

    what is AcDbObjectId? when used, shouldn't it need to be instantiated with a pointer?

  2. #2
    Member
    Join Date
    2012-01
    Posts
    4
    Login to Give a bone
    0

    Default Re: why does this line of code work?

    >what is AcDbObjectId?

    It is an ObjectARX class. It represents a somewhat generic identification of an AutoCAD Object.

    >shouldn't it need to be instantiated with a pointer?

    A class can be instantiated without having to call new. i.e.
    AcDbObjectId currentViewPortId = acedGetCurViewportObjectId();

    >why does this line of code work?

    This is the real question! I believe what is going on is the AutoCAD ObjectARX developers have overwritten the = sign to make it a copy constructor. They are trying to initialize an object id by saying this value is NULL. The AcDbObjectId class has two methods, isNull and SetNull. You can use these two methods later to see if you have a valid AcDbObjectId or invalidating an AcDbObjectId. The K::Null is another way of setting it the lineId to NULL.

    You might want to try,

    AcDbObjectId lineId;
    pBlockTableRecord->appendAcDbEntity(lineId, pLine);

    and see if it works. The = AcDbObjectId::kNull might not be needed at all.

    Paul

    Quote Originally Posted by chris.kulhanek View Post
    can someone help me? why does this line of code work?

    AcDbObjectId lineId = AcDbObjectId::kNull;
    pBlockTableRecord->appendAcDbEntity(lineId, pLine);

    shouldn't it be this....


    AcDbObjectId *lineId = new AcDbObjectid();
    pBlockTableRecord->appendAcDbEntity(lineId, pLine);

    what is AcDbObjectId? when used, shouldn't it need to be instantiated with a pointer?

Similar Threads

  1. Can't get the hello revit vb code to work
    By Jimbob in forum Revit - API
    Replies: 4
    Last Post: 2011-05-20, 07:22 PM
  2. Compiled VBA code does not work on other PCs
    By hulin40 in forum VBA/COM Interop
    Replies: 3
    Last Post: 2006-07-24, 03:32 AM
  3. Replies: 16
    Last Post: 2006-01-20, 04:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •