Jump to content

Recommended Posts

Posted

Hi All,

I'm using vb.net to write a DLL that I can load with netload.

How can I set the drawing's Units to meters? I would also like to change the precision from the default 0.0000 to 0.000.

All suggestions are appreciated.

Jozi68

Posted

The Database.Aunits (via DistanceUnitFormat enum) and Database.Auprec Properties allow for that type of modification

Posted

Thanx SEANT,

could you please show me how to do it? I am a complete beginner with VB.net

Posted

For the most part I would use C# for .NET programming. I will use this example request as an opportunity to practice a bit of VB, but I will need a day or two.

 

Same goes for your post regarding World UCS. I didn’t have time to respond this morning, but I’ll look into it that over the next few days.

Posted

Here is a basic routine to modify the unit format and display precision for a drawing.

 

With the header:

 

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.DatabaseServices

Imports Autodesk.AutoCAD.EditorInput

 

And within a Public Class:

 

    <CommandMethod("Test")> _
   Public Sub TestUnitsAndUcsMod()
       Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database

       Dim intInsLUnit As UnitsValue = db.Insunits
       Dim intLPrec As Integer = db.Luprec
       DisplayInfo(intInsLUnit, intLPrec, False)


       db.Insunits = UnitsValue.Meters
       db.Luprec = 3

       intInsLUnit = db.Insunits
       intLPrec = db.Luprec
       DisplayInfo(intInsLUnit, intLPrec, True)

   End Sub

   Private Sub DisplayInfo(ByVal UnitsFormat As UnitsValue, ByVal Precision As Integer, ByVal Changed As Boolean)
       Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
       Dim strUnitsFormat = UnitsFormat.ToString()
       Dim strPrec = Precision.ToString()
       Dim strChanged As String = "Former units were "
       If Changed Then strChanged = "New units are "

       ed.WriteMessage(strChanged & strUnitsFormat & " with a display precision to " & strPrec & " decimal places." & vbLf)
   End Sub

Posted

Thank you so much SEANT! It works beautifully. I really appreciate your help.

regards,

Jozi68

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...