Author Topic: VB Newbie - Cloning Styles for a Conversion Routine, Difficulty Level  (Read 1376 times)

0 Members and 1 Guest are viewing this topic.

Chillme1

  • Newt
  • Posts: 57
  • Must learn to earn!
I would like to ask questions or see examples from those who have developed a conversion routine involving dimension and/or text styles and that are based on a cloned version of a CAD Standard-based DIMSTYLE?

QUESTION 1: How difficult in the length or in the complexity of code is it to obtain a clone and apply the clone's proerties to these (dimension or text) type of entities?  :oops:
Thanks, Clint
Mechanical Designer / Process Piping
AutoCAD Toolsets 2022
Newbie Betimes - LISP Programmer

Jeff H

  • Needs a day job
  • Posts: 6150
Re: VB Newbie - Cloning Styles for a Conversion Routine, Difficulty Level
« Reply #1 on: October 11, 2011, 01:09:14 PM »
If I understand your question I think DeepClone will do fine then change whatever properties needed
 
Code: [Select]
        <CommandMethod("CloneTextDimStyle")> _
        Public Sub CloneTextDimStyle()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
 
            Using trx As Transaction = db.TransactionManager.StartTransaction()
 
                Dim dimTbl As DimStyleTable = trx.GetObject(db.DimStyleTableId, OpenMode.ForWrite)
                Dim dimBtr As DimStyleTableRecord = trx.GetObject(dimTbl("Standard"), OpenMode.ForRead)
 
                Dim dimMap As New IdMapping
                Dim newDimBtr As DimStyleTableRecord = dimBtr.DeepClone(dimTbl, dimMap, True)
                newDimBtr.Name = String.Format("{0} (Clone)", dimBtr.Name)
 
                newDimBtr.Dimalt = Not newDimBtr.Dimalt
                newDimBtr.Dimaltd = newDimBtr.Dimaltd + 1
 
                dimTbl.Add(newDimBtr)
                trx.AddNewlyCreatedDBObject(newDimBtr, True)
 
                trx.Commit()
            End Using
        End Sub
 

Chillme1

  • Newt
  • Posts: 57
  • Must learn to earn!
Re: VB Newbie - Cloning Styles for a Conversion Routine, Difficulty Level
« Reply #2 on: October 19, 2011, 06:23:34 AM »
I appreciate the code snippet and will try it and get back to you. It may be a while!
Thanks, Clint
Mechanical Designer / Process Piping
AutoCAD Toolsets 2022
Newbie Betimes - LISP Programmer