Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to find the acadblockreference (Autocad) by using the acadblock i got acadentity of acadblock but can not find the acadblockreference of that acadentity. How can i find it.

-- Amol
Posted
Updated 19-Jan-12 0:58am
v3
Comments
M_Mogharrabi 5-Apr-14 4:15am    
Hi Gangawane, I have the same problem, how did you solve it?

Autodesk has a very complete API reference and lots of examples on their site. I suggest you start there or reach out to your VAR if you still get stuck.

But, in general, ACAD drawings are structured sort of like XML or the Excel object model where the organization is hierarchical. At the top is the application, below that is the drawing(s), below that is layers, blocks, etc. To get a reference to a block you have to know the name of the block to access it directly through the block collection or iterate through it until you find the one you want. I know, for a fact, there are code examples out there if you search AutoDesk's web site and Google.
 
Share this answer
 
Better to look in the API documentation
To give you an idea where to start:
You will not get direct access to a block you will have to iterate over the block table.

---------------------

C#
using Autodesk.AutoCAD.DatabaseServices;


BlockTable _bt = (BlockTable)_t.GetObject(_cdb.BlockTableId, OpenMode.ForRead, false);
foreach (ObjectId btrId in _bt)
{
    BlockTableRecord _btr = (BlockTableRecord)_t.GetObject(btrId, OpenMode.ForRead, false);
    if (!_btr.IsAnonymous && !_btr.IsLayout && (_btr.IsFromExternalReference || _btr.IsFromOverlayReference))
    {
        Boolean _PathIsRelative = false;
        String _xrefPath = _btr.PathName;
        String _PathAbsolute = XRefRelink.Helper.RelativePath.GetPathAbsolute(_currentPath, _xrefPath);
        if (_PathAbsolute.ToUpper() != _xrefPath.ToUpper())
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900