Retriving data from Drawing

Retriving data from Drawing

Anonymous
Not applicable
317 Views
4 Replies
Message 1 of 5

Retriving data from Drawing

Anonymous
Not applicable
Hello I am a newbie on AutoCAD customization and I have no idea how to solving this problem: we have pdf file and there is a drawing number. After draft other people review it and put tag on the drawing. To do so reviewer manually types drawing number into tag. Is there any way you can retrieve these data without opening the drawing?

Paul
0 Likes
318 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Can you be more specific as to what the process is
that is being used?  What do you mean by a "tag"?  And how is it being
put "on" the drawing?  If the "tag" is being put into the drawing database,
then you will have to access the drawing itself.  However, this may be
transparent to the user.  For example, using ARX you can call the
readDwgFile( ) command to pull in the drawing database without actually opening
the drawing in the editor.  Is that what you're asking?


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hello
I am a newbie on AutoCAD customization and I have no idea how to solving this
problem: we have pdf file and there is a drawing number. After draft other
people review it and put tag on the drawing. To do so reviewer manually types
drawing number into tag. Is there any way you can retrieve these data without
opening the drawing?

Paul

0 Likes
Message 3 of 5

Anonymous
Not applicable
yes that's exactly what I am looking for you think you can give me more detail on that? And also could you recommend me some ARX reference book if you know any.
Thank you
Paul
0 Likes
Message 4 of 5

Anonymous
Not applicable
The readDwgFile is actually pretty simple to
use.  First you create a new AcDbDatabase, sending it an Adesk::kFalse to
ensure that the new DB is completely empty (since we're going to be reading a DB
in with the next command).  Next we call the readDwgFile with the path to
the file we wish to examine.  Once we've read in the file, we can now do
whatever we like to the DWG.  For example, perhaps we want to count the
number of circles in the drawing:

 

(i haven't actually tested this code, so don't
assume it's going to compile and run flawlessly!  Most of the code came
from one of my apps though, so most of it should be fine)

 

// Create a new AcDbDatabase pointer, and point it
at a completely empty DB

AcDbDatabase *pDb = new
AcDbDatabase(Adesk::kFalse);

 

// Read in the DWG file you wish to
manipulate

pDb->readDwgFile(fileName);

 

// Get the block table of our new DB

AcDbBlockTable *pBlockTable;
es =
pDb->getBlockTable(pBlockTable, AcDb::kForRead);
if(es !=
Acad::eOk)
{
    CString a;
   
a.Format("Failed to get block table %d", es);
   
AfxMessageBox(a);
    return;
}
 
// Now retrive
the block table record that corresponds to model space.
AcDbBlockTableRecord
*pBlockTableRecord;
es =
pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,
AcDb::kForWrite);
if(es != Acad::eOk)
{
    CString
a;
    a.Format("Failed to get block table record : %d",
es);
    AfxMessageBox(a);
   
pBlockTable->close();
    return;
}
 
// We
have model space, so close the main
table.
pBlockTable->close();

 

// Create an iterator to step through the
entities
// contained in model space.
AcDbBlockTableRecordIterator
*pBlockIterator;
es =
pBlockTableRecord->newIterator(pBlockIterator);
if(es !=
Acad::eOk)
{
    CString a;
   
a.Format("%d",es);
   
pBlockTable->close();
   
pBlockTableRecord->close();
    AfxMessageBox("Failed to
create a new iterator: " + a);
    return;
}

 

// Integer variable to store the number of
circles.

int circleCount;

 

// We now have a valid iterator.  Step through
all of the entities and

// count the circles. 
for (;
!pBlockIterator->done(); pBlockIterator->step())
{

 

    // Create a NULL entity pointer
to be used in the next

    // statement.

    AcDbEntity *pEntity =
NULL;
       

    // Open the entity pointed
to by the
iterator
    pBlockIterator->getEntity(pEntity,
AcDb::kForRead);
       

    // Now check to see if the
entity is a circle


size=2>    if(pEntity->isKindOf(AcDbCirlce))

    {

       
circleCount++;

    }

   

}

 

// We're done iterating.  Delete the iterator
and close the block table record

delete
pBlockIterator;
pBlockTableRecord->close();

// Now do something with the
circleCount...
0 Likes
Message 5 of 5

Anonymous
Not applicable
As to the book, i think most of us here would
recommend that you get started with "Programming AutoCAD 2000 Using ObjectARX"
by Charles McAuley.  If you're not already a C++ programmer, however, you
may want to start by going through the basics with any Visual C++ beginners
book.  You can certainly jump right in and start with ARX, but it helps to
have some basic knowledge of how C++ works.  Two years ago when i first
looked at ARX i had very little C++ knowledge (though i had programmed quite a
bit in VB), and i struggled to get ANYTHING to work right.  After a few
beginners C++ books, though, everything seemed to make a lot more sense... 
Good luck.
0 Likes