Do not open file traversal Blocks

Source: Internet
Author: User

// Traverse the current DWG block (do not open the file)
BOOL CPushDbDlg: TraverBlock (CString dwgpath, int type)
{
Acad: ErrorStatus es;

AcApDocument * pDoc = acDocManager-> curDocument (); // lock the document
Es = acDocManager-> lockDocument (pDoc );
If (es! = Acad: eOk)
{
AcutPrintf ("failed to lock the document ");
Return es;
}

AcDbBlockTable * ptlb;
Pdb-> getSymbolTable (ptlb, AcDb: kForRead );
AcDbBlockTableRecord * prec;
AcDbBlockTableRecord * precT;
Ptlb-> getAt (ACDB_MODEL_SPACE, prec, AcDb: kForRead );
Ptlb-> close ();
 
AcDbBlockTableRecordIterator * piter;
Prec-> newIterator (piter );
AcDbObjectIdArray idArray;
For (piter-> start ();! Piter-> done (); piter-> step ())
{
AcDbEntity * pentity;
Piter-> getEntity (pentity, AcDb: kForRead );
If (pentity-> isKindOf (AcDbBlockReference: desc ()))
{
IdArray. append (pentity-> objectId ());

}
Pentity-> close ();
}
Delete piter;
Prec-> close ();


AcDbObjectId Aobjectid = pIterator-> objectId ();
Es = acdbOpenAcDbObject (AcDbObject * &) pAEntity, Aobjectid, AcDb: kForRead );
If (es! = Acad: eOk)
{
AcutPrintf ("failed to open the object ");
Break;
}
PAtt = AcDbAttribute: cast (pAEntity );
Char * szTag = "";
If (pAtt! = NULL)
{
SzTag = pAtt-> tag ();
}
If (pAtt! = NULL/* & strBlockName = "title bar" */& type = 1) // write block information to a file
{
If (strcmp (szTag, "sketch drawing") = 0)
{
Char * sztext = patt-> textstring ();
Strdrawer = sztext;
}
Else if (strcmp (sztag, "Graph category") = 0)
{
Char * sztext = patt-> textstring ();
Strcate = sztext;
}
Else if (strcmp (sztag, "Drawing Number") = 0)
{
Char * sztext = patt-> textstring ();
Strcode = sztext;
}
Else if (strcmp (szTag, "workshop director") = 0)
{
Char * szText = pAtt-> textString ();
StrDirector = szText;
}
Else if (strcmp (szTag, "mobile location") = 0 ){
Char * szText = pAtt-> textString ();
StrPlant = szText;
}
If (strDirector = "") // if there is no workshop director
{
If (strcmp (szTag, "device Director") = 0)
{
Char * szText = pAtt-> textString ();
StrDirector = szText;
}
}

}
Else if (pAtt! = NULL & type = 2) // write each block
{
If (strcmp (szTag, "device number") = 0)
{
Char * szText = pAtt-> textString ();
StrECode = szText;
M_list.GetItem (iCur, strDrawCode );
// Write the data to the database
This-> WriteBlockDb (strDrawCode, strBlockCode, strECode );
}
}
}
PAEntity-> close ();
PAtt-> close ();
Delete pIterator;
Pref-> close ();
}
Delete pworkiter;
}
Pobj-> close ();
}
Delete pdb;
Pdb = NULL;
 
Es = acDocManager-> unlockDocument (pDoc );
Return TRUE;

}
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.