ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VS2010 and DWG Attributes

1 REPLY 1
Reply
Message 1 of 2
alberich2k5
271 Views, 1 Reply

VS2010 and DWG Attributes

Hello Guys!

I'm new to autocad and visual studio. I'm trying to build a simple aplication that uses com interop with autocad. It creates an acad aplication. uses it to open a file, get the blocks and finally its attributes.

My problem is that on the attributes, i'm not able to get the value of the attribute. When i try att.textvalue I get and empty string.  Can anyone help me on this one?

Thanks!!

Here is my very simple code:

 

Autodesk.AutoCAD.Interop.AcadDocument doc = _acad.Documents.Open(dwgpath, true, string.Empty);
Autodesk.AutoCAD.Interop.Common.AcadDatabase myDB = doc.Database;
Autodesk.AutoCAD.Interop.Common.AcadBlocks blocks = myDB.Blocks;

Autodesk.AutoCAD.Interop.Common.AcadBlock selblk = null;


foreach (Autodesk.AutoCAD.Interop.Common.AcadBlock myblock in blocks)
{
    String myBlkName = myblock.Name.ToString();
    
    if (String.Compare(myBlkName.ToLower(), "BOTTOMBLK_2") == 0)
    {
        selblk = myblock;
    }

}

if (selblk == null)
{
    return;
}

foreach (Autodesk.AutoCAD.Interop.Common.AcadEntity ent in selblk)
{
    Autodesk.AutoCAD.Interop.Common.AcadAttribute att = ent as Autodesk.AutoCAD.Interop.Common.AcadAttribute;

    if (att != null)
    {
        MessageBox.Show("EntityName = " + att.TextString);
        MessageBox.Show("EntityName = " + att.TagString);
        /*
        MessageBox.Show("EntityName = " + att.TagString +
                        "\n Entity Prompt String = " + att.PromptString +
                       "\n Entity Text String = " + att.TextString.ToCharArray() +
                        "\n Entity Text String = " + att.TextString);

        */
    }
}

 

1 REPLY 1
Message 2 of 2
owenwengerd
in reply to: alberich2k5

If you're trying to find attributes that belong to a particular block reference, you'll need to first get the block reference. You're more likely to get help in the VBA or .NET discussion groups, as this group is for C++.

--
Owen Wengerd
ManuSoft

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost