Jump to content

Access a closed drawing


Recommended Posts

Posted

I have a code which changes the dimension style in a drawing

from DimStyle1 to Dimstyle2

 

Is it possible to change from dimstyle1 to dimstyle2 if dimstyle2 was on a closed drawing. If so What changes should I make to my code.

 

 
Public Class Class2
<CommandMethod("changedimstyle")> _
Public Sub ChangeDimStyle()
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.ForRead)
Dim dimDtr As DimStyleTableRecord = trx.GetObject(dimTbl("DimStyle1"), OpenMode.ForRead)
Dim ids As ObjectIdCollection = dimDtr.GetPersistentReactorIds()
For Each objId As ObjectId In ids
If objId.ObjectClass.IsDerivedFrom(RXClass.GetClass(GetType(Dimension))) Then
Dim dimen As Dimension = trx.GetObject(objId, OpenMode.ForWrite)
dimen.DimensionStyleName = "DimStyle2"
End If
Next
trx.Commit()
End Using
End Sub
End Class

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...