Hi,
i have my own plugin to check drawings to apply our company standard.
One of the functions must be a check on the DrawingUnits within the Civil Drawingsettings.
I am able to check the current Unit settings, but it fails to change the settings.
What i want is when the current Unit Settings are other then Meters to set the current settings to Meters.
My code:
Dim civilDoc As CivilDocument = Autodesk.Civil.ApplicationServices.CivilApplication.ActiveDocument
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Using trans As Transaction = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction()
Try
Dim civilUnits As String = civilDoc.Settings.DrawingSettings.UnitZoneSettings.DrawingUnits.ToString
If Not civilUnits = "Meters" Then
ed.WriteMessage("Change UNITS from : " & civilUnits & " to Meters")
civilDoc.Settings.DrawingSettings.UnitZoneSettings.DrawingUnits = Settings.DrawingUnitType.Meters
End If
Catch ex As Autodesk.Civil.CivilException
ed.WriteMessage("Exception Message is : " & ex.Message.ToString())
Finally
trans.Commit()
End Try
End Using
The above code results in the following error:
************** Exception Text **************
System.ArgumentNullException: Value cannot be null.
at Autodesk.Civil.AttributeHelper.putAttributeGeneric<int>(UInt32 attributeId, IAeccAttributeBin* pAttrBin, Int32 newValue, AeccUserParam* userParam)
at Autodesk.Civil.AttributeHelper.putAttributeInt(UInt32 attributeId, AcDbObjectId* ObjectId, Int32 newValue)
at Autodesk.Civil.Settings.SettingsUnitZone.set_DrawingUnits(DrawingUnitType newValue)
at AnaconToolSet.tabProcessDrawing.checkCivilDrawingSettings()
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Is there somebody who can point me in the right direction?