Announcement

Collapse
No announcement yet.

A very beginner question in elevation from c# in Visual studio

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    A very beginner question in elevation from c# in Visual studio

    Hi there,
    I am new to API and I am following a textbook to generate elevations from script. It works well but when I set the elevation to 10.0 it shows up as 3.408. No matter what value I entered, it is always a value reduced to 34.08%. So the only correct elevation is 0.0.
    Is anybody aware what goes wrong with my code please?

    Many thanks.

    Code:
             
             public Result Execute (ExternalCommandData commandData, ref string messages, ElementSet elements)        {
                UIApplication uiApp = commandData.Application;  
                Autodesk.Revit.ApplicationServices.Application app = uiApp.Application; 
                Document doc = uiApp.ActiveUIDocument.Document; 
                
                //Level level = Elements as Level;
                Level [] level = new Level[3];
                using (Transaction transaction = new Transaction(doc))
                {
                    transaction.Start("Create Level");
                    
                    level[0] = Level.Create(doc, 0.0);
                    LevelType levelType = doc.GetElement(level[0].GetTypeId()) as LevelType;
                    Parameter relativeBaseType = levelType.get_Parameter(BuiltInParameter.LEVEL_RELATIVE_BASE_TYPE);
                    relativeBaseType.Set(1); 
                    
                    level[1] = Level.Create(doc, 5.3);
                    level[2] = Level.Create(doc, 10.0);
                    transaction.Commit();
                }
             }

    #2
    Oh I thought it might be some unit conversion stuff...Figuring it out

    Comment


      #3
      Typical convertions

      Reading: UnitUtils.ConvertFromInternalUnits(parameter.AsDou ble(), parameter.DisplayUnitType);
      Wrtiting: parameter.Set(UnitUtils.ConvertToInternalUnits(val ue, parameter.DisplayUnitType));
      Gonçalo Feio
      "Ignorance, ignorance, sheer ignorance - you know there's no confidence to equal it. It's only when you know something about a profession, I think, that you're timid and careful." George Orson Welles

      Comment

      Related Topics

      Collapse

      Working...
      X