当前位置: 首页>>代码示例>>C#>>正文


C# Application.OpenSharedParameterFile方法代码示例

本文整理汇总了C#中Application.OpenSharedParameterFile方法的典型用法代码示例。如果您正苦于以下问题:C# Application.OpenSharedParameterFile方法的具体用法?C# Application.OpenSharedParameterFile怎么用?C# Application.OpenSharedParameterFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Application的用法示例。


在下文中一共展示了Application.OpenSharedParameterFile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSharedParameterFile

        /// <summary>
        /// Get shared parameter DefinitionFile of given Revit DB Application.
        /// </summary>
        /// <param name="revitApp">Revit DB Application</param>
        /// <returns>DefinitionFile of Revit DB Application</returns>
        public static DefinitionFile GetSharedParameterFile(Application revitApp)
        {
            DefinitionFile file = null;

            int count = 0;
            // A count is to avoid infinite loop
            while (null == file && count < 100)
            {
                file = revitApp.OpenSharedParameterFile();
                if (file == null)
                {
                    // If Shared parameter file does not exist, then create a new one.
                    string shapeFile =
                        Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
                        + "\\MultiplanarParameterFiles.txt";

                    // Fill Schema data of Revit shared parameter file.
                    // If no this schema data, OpenSharedParameterFile may alway return null.
                    System.Text.StringBuilder contents = new System.Text.StringBuilder();
                    contents.AppendLine("# This is a Revit shared parameter file.");
                    contents.AppendLine("# Do not edit manually.");
                    contents.AppendLine("*META	VERSION	MINVERSION");
                    contents.AppendLine("META	2	1");
                    contents.AppendLine("*GROUP	ID	NAME");
                    contents.AppendLine("*PARAM	GUID	NAME	DATATYPE	DATACATEGORY	GROUP	VISIBLE");

                    // Write Schema data of Revit shared parameter file.
                    File.WriteAllText(shapeFile, contents.ToString());

                    // Set Revit shared parameter file
                    revitApp.SharedParametersFilename = shapeFile;
                }

                // To avoid infinite loop.
                ++count;
            }

            return file;
        }
开发者ID:AMEE,项目名称:revit,代码行数:44,代码来源:SharedParameterUtil.cs

示例2: GetSharedParamsFile

        /// <summary>
        /// Get shared parameters file.
        /// </summary>
        public static DefinitionFile GetSharedParamsFile(
            Application app)
        {
            string sharedParamsFileName
            = app.SharedParametersFilename;

              if ( 0 == sharedParamsFileName.Length
            || null == app.OpenSharedParameterFile() )
              {
            StreamWriter stream;
            stream = new StreamWriter( SharedParameterFilePath );
            stream.Close();

            app.SharedParametersFilename = SharedParameterFilePath;
            sharedParamsFileName = app.SharedParametersFilename;
              }

              // Get the current file object and return it.

              DefinitionFile sharedParametersFile
            = app.OpenSharedParameterFile();

              return sharedParametersFile;
        }
开发者ID:jeremytammik,项目名称:FireRatingCloud,代码行数:27,代码来源:Util.cs

示例3: SharedParamGuid

 /// <summary>
 /// Get GUID for a given shared param name.
 /// </summary>
 /// <param name="app">Revit application</param>
 /// <param name="defGroup">Definition group name</param>
 /// <param name="defName">Definition name</param>
 /// <returns>GUID</returns>
 static Guid SharedParamGuid( Application app, string defGroup, string defName )
 {
     Guid guid = Guid.Empty;
     try
     {
       DefinitionFile file = app.OpenSharedParameterFile();
       DefinitionGroup group = file.Groups.get_Item( defGroup );
       Definition definition = group.Definitions.get_Item( defName );
       ExternalDefinition externalDefinition = definition as ExternalDefinition;
       guid = externalDefinition.GUID;
     }
     catch( Exception )
     {
     }
     return guid;
 }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:23,代码来源:CmdListSharedParams.cs

示例4: SharedParamGuid

 /// <summary>
 /// Return GUID for a given shared parameter group and name.
 /// </summary>
 /// <param name="app">Revit application</param>
 /// <param name="defGroup">Definition group name</param>
 /// <param name="defName">Definition name</param>
 /// <returns>GUID</returns>
 public static Guid SharedParamGuid(
     Application app,
     string defGroup,
     string defName)
 {
     DefinitionFile file = app.OpenSharedParameterFile();
       DefinitionGroup group = ( null == file )
     ? null : file.Groups.get_Item( defGroup );
       Definition definition = ( null == group )
     ? null : group.Definitions.get_Item( defName );
       ExternalDefinition externalDefinition
     = ( null == definition )
       ? null : definition as ExternalDefinition;
       return ( null == externalDefinition )
     ? Guid.Empty
     : externalDefinition.GUID;
 }
开发者ID:jeremytammik,项目名称:FireRatingCloud,代码行数:24,代码来源:Util.cs

示例5: AccessOrCreateSharedParameterFile

        /// <summary>
        /// Access an existing or create a new shared parameters file.
        /// </summary>
        /// <param name="app">Revit Application.</param>
        /// <returns>the shared parameters file.</returns>
        private static DefinitionFile AccessOrCreateSharedParameterFile(Application app)
        {
            // The location of this command assembly
             string currentCommandAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;

             // The path of ourselves shared parameters file
             string sharedParameterFilePath = Path.GetDirectoryName(currentCommandAssemblyPath);
             sharedParameterFilePath        = sharedParameterFilePath + "\\MySharedParameterFile.txt";

             //Method's return
             DefinitionFile sharedParameterFile = null;

             // Check if the file exits
             System.IO.FileInfo documentMessage = new FileInfo(sharedParameterFilePath);
             bool fileExist                     = documentMessage.Exists;

             // Create file for external shared parameter since it does not exist
             if (!fileExist)
             {
            FileStream fileFlow = File.Create(sharedParameterFilePath);
            fileFlow.Close();
             }

             // Set ourselves file to the externalSharedParameterFile
             app.SharedParametersFilename = sharedParameterFilePath;
             sharedParameterFile                  = app.OpenSharedParameterFile();

             return sharedParameterFile;
        }
开发者ID:AMEE,项目名称:revit,代码行数:34,代码来源:DoorSharedParameters.cs

示例6: GetSharedParamsFile

    /// <summary>
    /// Helper to get shared parameters file.
    /// </summary>
    public static DefinitionFile GetSharedParamsFile(Application app)
    {
      // Get current shared params file name
      string sharedParamsFileName;
      try
      {
        sharedParamsFileName = app.SharedParametersFilename;
      }
      catch (Exception ex)
      {
        TaskDialog.Show("Get shared params file", "No shared params file set:" + ex.Message);
        return null;
      }

      if (0 == sharedParamsFileName.Length ||
        !System.IO.File.Exists(sharedParamsFileName))
      {
        StreamWriter stream;
        stream = new StreamWriter(kSharedParamsPath);
        stream.Close();
        app.SharedParametersFilename = kSharedParamsPath;
        sharedParamsFileName = app.SharedParametersFilename;
      }

      // Get the current file object and return it
      DefinitionFile sharedParametersFile;
      try
      {
        sharedParametersFile = app.OpenSharedParameterFile();
      }
      catch (Exception ex)
      {
        TaskDialog.Show("Get shared params file", "Cannnot open shared params file:" + ex.Message);
        sharedParametersFile = null;
      }
      return sharedParametersFile;
    }
开发者ID:FlintSable,项目名称:RevitTrainingMaterial,代码行数:40,代码来源:7_SharedParameter.cs

示例7: CreateProjectParameter

        /// <summary>
        /// create project parameter
        /// source :http://spiderinnet.typepad.com/blog/2011/05/parameter-of-revit-api-31-create-project-parameter.html
        /// </summary>
        /// <param name="app">revit application</param>
        /// <param name="name">revit ui application</param>
        /// <param name="type">parameter type</param>
        /// <param name="cats">category set</param>
        /// <param name="group">parameter group</param>
        /// <param name="inst">is instance variable</param>
        public  void CreateProjectParameter(Application app, string name, ParameterType type,  CategorySet cats, BuiltInParameterGroup group, bool instance)
        {
    

            string oriFile = app.SharedParametersFilename;
            string tempFile = Path.GetTempFileName() + ".txt";
            using (File.Create(tempFile)) { }
            app.SharedParametersFilename = tempFile;
    
             ExternalDefinitionCreationOptions edc=new ExternalDefinitionCreationOptions(name, type);
             ExternalDefinition def = app.OpenSharedParameterFile().Groups.Create("TemporaryDefintionGroup").Definitions.Create(edc) as ExternalDefinition;

            app.SharedParametersFilename = oriFile;
            File.Delete(tempFile);

            Autodesk.Revit.DB.Binding binding = app.Create.NewTypeBinding(cats);
            if (instance) binding = app.Create.NewInstanceBinding(cats);
            BindingMap map = (new UIApplication(app)).ActiveUIDocument.Document.ParameterBindings;
            map.Insert(def, binding, group);
        }
开发者ID:baselqyqony,项目名称:REVIT_API_SCHEDULE_UTIL,代码行数:30,代码来源:ScheduleUtil.cs

示例8: SharedParamGuid

 /// <summary>
 /// Return GUID for a given shared parameter group and name.
 /// </summary>
 /// <param name="app">Revit application</param>
 /// <param name="defGroup">Definition group name</param>
 /// <param name="defName">Definition name</param>
 /// <returns>GUID</returns>
 public static Guid SharedParamGuid(
   Application app,
   string defGroup,
   string defName )
 {
   DefinitionFile file = app.OpenSharedParameterFile();
   DefinitionGroup group = file.Groups.get_Item( defGroup );
   Definition definition = group.Definitions.get_Item( defName );
   ExternalDefinition externalDefinition = definition as ExternalDefinition;
   return externalDefinition.GUID;
 }
开发者ID:jaimerosales,项目名称:FireRatingCloud,代码行数:18,代码来源:Util.cs


注:本文中的Application.OpenSharedParameterFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。