.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Drawing Units

2 REPLIES 2
Reply
Message 1 of 3
SRSDS
315 Views, 2 Replies

Drawing Units

Hi all again,

Can I access the units of the CANNOSCALE scale rather than the string value?

Each new scale needs a Paper Scale and Drawing Units input values and I'd like to be able to adjust a block insert based on this ratio. TBH I don't understand why paper scale isn't always 1 but probably irelevant.

 

2 REPLIES 2
Message 2 of 3
Balaji_Ram
in reply to: SRSDS

Here is a code snippet to obtain the paperunits and drawingunits corresponding to the scale :

 

<code>

            Database db = HostApplicationServices.WorkingDatabase;
            try
            {
                ObjectContextManager contextManager = db.ObjectContextManager;
                if (contextManager != null)
                {
                    ObjectContextCollection contextCollection =

                                                             contextManager.GetContextCollection("ACDB_ANNOTATIONSCALES");
                    if (contextCollection != null)
                    {
                        foreach (ObjectContext oc in contextCollection)
                        {
                            AnnotationScale annoscale = oc as AnnotationScale;
                            if(annoscale != null)
                            {
                                // annoscale.Name;
                                // annoscale.PaperUnits;
                                // annoscale.DrawingUnits;
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                ed.WriteMessage(ex.ToString());
            } 

</code>

 

Also, the paper units need not be always 1. This is because, 1 drawing unit may be represented by X paper units. It is sometimes simpler to use x:1 rather than 1:(1/X).



Balaji
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
SRSDS
in reply to: Balaji_Ram

Thank Balaji !

I changed this line to check the current scale.

if (annoscale != null & annoscale.Name == db.Cannoscale.Name) {

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost