TheSwamp

Code Red => .NET => Topic started by: Chillme1 on June 21, 2011, 07:27:38 AM

Title: 1.) Update Block Inserts 2.) Rename Attribute Tags, Retain Attribute Value
Post by: Chillme1 on June 21, 2011, 07:27:38 AM
I would like to understand how to perform the following operations using AutoCAD 2011 and VB.NET Visual Studio 2010 Express.

Could someone provide any code snippets or pseudo code for the following to get me started?


Issue 1 - Update Block Inserts

What steps would be required to update block inserts based on referencing the source block's folder or possibly specifying more than one folder from which the block inserts can be updated from?

Issue 2 - Rename Attribute Tag Names & Retain Values

What steps would be required to rename attribute tags and retain the attribute values?
Title: Re: 1.) Update Block Inserts 2.) Rename Attribute Tags, Retain Attribute Value
Post by: kaefer on June 21, 2011, 08:08:58 AM
What steps would be required to update block inserts based on referencing the source block's folder or possibly specifying more than one folder from which the block inserts can be updated from?

This is actual code in a slightly unusual language, so it should fit your bill. It defines an extension method to Database which does the updating of the block definitions via a side database, you'd need to wrap in a loop for your list of file names.

Code: [Select]
type Database with
    member destDb.InsertBlock fileName =
        let destBlockName =
            SymbolUtilityServices.GetSymbolNameFromPathName(fileName, "dwg")
        let destBlockName =
            SymbolUtilityServices.RepairSymbolName(destBlockName, false)
        use db = new Database(false, true)
        // Read the DWG into our side database
        db.ReadDwgFile(fileName, System.IO.FileShare.Read, true, "")
        let srcIsAnnotative = db.AnnotativeDwg
        destDb.Insert(destBlockName, db, false) |> ignore
        // Returns block name * bool (true if annotatiove)
        destBlockName, srcIsAnnotative

Quote
What steps would be required to rename attribute tags and retain the attribute values?

That one may be straightforward, the AttributeReference.Tag property is settable.

Cheers
Title: Re: 1.) Update Block Inserts 2.) Rename Attribute Tags, Retain Attribute Value
Post by: mohnston on June 21, 2011, 12:27:08 PM
I've never seen RepairSymbolName used.
What does it do?
Title: Re: 1.) Update Block Inserts 2.) Rename Attribute Tags, Retain Attribute Value
Post by: Chillme1 on June 21, 2011, 12:52:08 PM
That snippet will help when I 'get my head around it'.
If you have any other advice on how to proceed with these tasks, I am open. :angel:
Title: Re: 1.) Update Block Inserts 2.) Rename Attribute Tags, Retain Attribute Value
Post by: kaefer on June 21, 2011, 01:32:09 PM
I've never seen RepairSymbolName used.
What does it do?

What the name says... Dan advised it (see comments here (http://through-the-interface.typepad.com/through_the_interface/2011/01/combining-autocad-blocks-in-separate-files-into-a-single-dwg-using-net-take-2.html)).