M_Mogharrabi
M_Mogharrabi

Reputation: 1389

change unit programmatically in autocad

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.

Upvotes: 0

Views: 1621

Answers (2)

kaps
kaps

Reputation: 186

The following chunk of code will help you.

Application.DocumentManager.MdiActiveDocument.Database.Insunits=UnitsValue.Feet;

Upvotes: 4

andyhasit
andyhasit

Reputation: 15309

The AutoCAD units represent "real world" distances, and pixels represent "on screen" distances. You need to decide what real world distance a pixel should equate to inside your dwg.

If you want the exact same size on screen you need to take into account zoom settings and so-on, and I wouldn't hold much hope of getting it all that accurate.

I would also avoid imperial measurements like the plague, especially for what you're doing. Set your AutoCAD to work with metric units unless you really must use imperial.

It seems a pretty trivial choice so I'd go for a very "linear" ratio for pixel to unit, like 1:1 or 1:100 and then play with the zoom.

Upvotes: 2

Related Questions