Author Topic: 1.) Update Block Inserts 2.) Rename Attribute Tags, Retain Attribute Value  (Read 2392 times)

0 Members and 1 Guest are viewing this topic.

Chillme1

  • Newt
  • Posts: 57
  • Must learn to earn!
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?
Thanks, Clint
Mechanical Designer / Process Piping
AutoCAD Toolsets 2022
Newbie Betimes - LISP Programmer

kaefer

  • Guest
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

mohnston

  • Bull Frog
  • Posts: 305
  • CAD Programmer
I've never seen RepairSymbolName used.
What does it do?
It's amazing what you can do when you don't know what you can't do.
CAD Programming Solutions

Chillme1

  • Newt
  • Posts: 57
  • Must learn to earn!
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:
Thanks, Clint
Mechanical Designer / Process Piping
AutoCAD Toolsets 2022
Newbie Betimes - LISP Programmer

kaefer

  • Guest
I've never seen RepairSymbolName used.
What does it do?

What the name says... Dan advised it (see comments here).