Author Topic: How to remove Dimension Z value  (Read 1300 times)

0 Members and 1 Guest are viewing this topic.

chobo

  • Newt
  • Posts: 24
How to remove Dimension Z value
« on: October 26, 2014, 02:40:41 AM »
I want to dimension objects z values to zero.
dimension's point(start/end) is remain unchanged.

Microsoft Visual Studio 2010, Target .NET Framework = 2.0
Code - vb.net: [Select]
  1.     <CommandMethod("dimtest")> _
  2.     Public Sub GetDim()
  3.         Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
  4.         Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
  5.         Try
  6.             Using acTr As Transaction = db.TransactionManager.StartTransaction
  7.                 Dim peo As New PromptEntityOptions(vbLf & "Select a Dimension:")
  8.                 peo.SetRejectMessage(vbLf & "Select Dimension only")
  9.                 peo.AddAllowedClass(GetType(Dimension), False)
  10.  
  11.                 Dim res As PromptEntityResult
  12.                 res = ed.GetEntity(peo)
  13.                 If res.Status <> PromptStatus.OK Then
  14.                     Return
  15.                 End If
  16.  
  17.                 Dim ent As Entity = CType(acTr.GetObject(res.ObjectId, OpenMode.ForRead), Entity)
  18.                 If ent Is Nothing Then
  19.                     Return
  20.                 End If
  21.  
  22.                 Dim diment As Dimension = TryCast(CType(ent, Dimension), Dimension)
  23.                 If diment Is Nothing Then
  24.                     ed.WriteMessage(vbLf & "Error: selected entity is not a Dimension")
  25.                     Return
  26.                 End If
  27.                 With diment
  28.                     .UpgradeOpen()
  29.                     .Elevation = 0
  30.                     .DowngradeOpen()
  31.                 End With
  32.  
  33.                 acTr.Commit()
  34.             End Using
  35.         Catch ex As Exception
  36.  
  37.         End Try
  38.     End Sub
  39.