change unit programmatically

change unit programmatically

Anonymous
Not applicable
811 Views
2 Replies
Message 1 of 3

change unit programmatically

Anonymous
Not applicable

hi everyone.

I'm using sendcommand to draw various shapes in autocad.

the problem is my application (wpf) uses pixel units while autocad uses inches by default.

how can I change autocad units to pixel programmatically?

thanks in advance.

0 Likes
812 Views
2 Replies
Replies (2)
Message 2 of 3

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

AutoCAD does not know a unit of type "pixel", however AutoCAD has a sysvar UNITMODE and you can change that in the database:

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.Unitmode

 

Important: AutoCAD does use this setting only for some functions like INSERT/XREF/... but at least the UNITs-setting is just for orientation for you and nothing else. If you draw a line of 20 length, for AutoCAD 20 is nothing else but 20 "AutoCAD-UNIT"s, it's not inch, not meter, not lightyears and so you can say: for me 1 AutoCAD-UNIT is 1 pixel.

 

More important is to use the command scale that gives the geometry the size you wish to have on the end (and if your drawing is inserted into any other drawing that is get's the size it should get ... and of course there is also no unit "pixel" in the nature). 😉

 

HTH, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 3

chiefbraincloud
Collaborator
Collaborator

As Alfred indicates, AutoCAD deals with things in "AutoCAD units", so It will make no difference in the drawing itself unless that drawing is exported to some other format, or imported into another drawing.

 

That said, if it is that important to you, you can modify the acad.unt file and add a definition for Pixel.  Just open it in a text editor and follow the pattern that is there.  The file is found under the AutoCAD program folder in the UserDataCache folder.

Dave O.                                                                  Sig-Logos32.png