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


C# FilteredElementCollector.get_Parameter方法代码示例

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


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

示例1: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
              UIDocument uidoc = uiapp.ActiveUIDocument;
              Document doc = uidoc.Document;

              if( doc.IsFamilyDocument )
              {
            message = "The document must be a project document.";
            return Result.Failed;
              }

              // Get the (singleton) element that is the
              // ProjectInformation object.  It can only have
              // instance parameters bound to it, and it is
              // always guaranteed to exist.

              Element projectInfoElement
            = new FilteredElementCollector( doc )
              .OfCategory( BuiltInCategory.OST_ProjectInformation )
              .FirstElement();

              // Get the first wall type element.  It can only
              // have type parameters bound to it, and there is
              // always guaranteed to be at least one of these.

              Element firstWallTypeElement
            = new FilteredElementCollector( doc )
              .OfCategory( BuiltInCategory.OST_Walls )
              .WhereElementIsElementType()
              .FirstElement();

              CategorySet categories = null;
              Parameter foundParameter = null;

              // Get the list of information about all project
              // parameters, calling our helper method, below.

              List<ProjectParameterData> projectParametersData
            = GetProjectParameterData( doc );

              // In order to be able to query whether or not a
              // project parameter is shared or not, and if it
              // is shared then what it's GUID is, we must ensure
              // it exists in the Parameters collection of an
              // element.
              // This is because we cannot query this information
              // directly from the project parameter bindings
              // object.
              // So each project parameter will attempt to be
              // temporarily bound to a known object so a
              // Parameter object created from it will exist
              // and can be queried for this additional
              // information.

              foreach( ProjectParameterData projectParameterData
            in projectParametersData )
              {
            if( projectParameterData.Definition != null )
            {
              categories = projectParameterData.Binding.Categories;
              if( !categories.Contains( projectInfoElement.Category ) )
              {
            // This project parameter is not already
            // bound to the ProjectInformation category,
            // so we must temporarily bind it so we can
            // query that object for it.

            using( Transaction tempTransaction
              = new Transaction( doc ) )
            {
              tempTransaction.Start( "Temporary" );

              // Try to bind the project parameter do
              // the project information category,
              // calling our helper method, below.

              if( AddProjectParameterBinding(
                doc, projectParameterData,
                projectInfoElement.Category ) )
              {
                // successfully bound
                foundParameter
                  = projectInfoElement.get_Parameter(
                    projectParameterData.Definition );

                if( foundParameter == null )
                {
                  // Must be a shared type parameter,
                  // which the API reports that it binds
                  // to the project information category
                  // via the API, but doesn't ACTUALLY
                  // bind to the project information
                  // category.  (Sheesh!)

                  // So we must use a different, type
                  // based object known to exist, and
//.........这里部分代码省略.........
开发者ID:sridharbaldava,项目名称:the_building_coder_samples,代码行数:101,代码来源:CmdProjectParameterGuids.cs

示例2: Execute

        public void Execute( UpdaterData data )
        {
            // we need to modify something here, or the
              // updater requirement will not be saved in
              // the document.

              Document doc = data.GetDocument();

              //Transaction t = new Transaction( doc,
              //  "Dummy Updater Transaction" );

              //t.Start();
              //t.Commit();

              //if( 0 < data.GetModifiedElementIds().Count )
              //{
              //  foreach( ElementId id in data.GetModifiedElementIds() )
              //  {
              //    Element e = doc.get_Element( id );
              //    Parameter p = e.get_Parameter( BuiltInParameter.ALL_MODEL_MARK );
              //    string s = p.AsString();
              //    p.Set( s + " modified by " + ToString() );
              //  }
              //}

              ProjectInfo a
            = new FilteredElementCollector( doc )
              .OfClass( typeof( ProjectInfo ) )
              .FirstElement() as ProjectInfo;

              try
              {

              Parameter p = a.get_Parameter(BuiltInParameter.PROJECT_STATUS);
              string s = p.AsString();
              if (s == null) s = string.Empty;
              if (0 < s.Length)
              {
              s += " ";
              }
              p.Set(s + "modified by " + ToString());

              Debug.Print("DummyUpdater.Execute: "
                      + GetUpdaterName() + " "
                      + GetUpdaterId());
              }
              catch (Exception ex)
              {
              var td = new TaskDialog("Error");
              td.MainInstruction = ex.Message;
              td.ExpandedContent = ex.ToString();
              td.Show();
              }
        }
开发者ID:vchekalin,项目名称:test,代码行数:54,代码来源:DummyUpdater.cs

示例3: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
              UIDocument uidoc = app.ActiveUIDocument;
              Document doc = uidoc.Document;

              #region Determine true north rotation

              Element projectInfoElement
            = new FilteredElementCollector( doc )
              .OfCategory( BuiltInCategory.OST_ProjectBasePoint )
              .FirstElement();

              BuiltInParameter bipAtn
            = BuiltInParameter.BASEPOINT_ANGLETON_PARAM;

              Parameter patn = projectInfoElement.get_Parameter(
            bipAtn );

              double atn = patn.AsDouble();

              Debug.Print(
            "Angle to north from project info: {0}",
            Util.AngleString( atn ) );

              #endregion // Determine true north rotation

              //ElementSet els = uidoc.Selection.Elements; // 2014

              ICollection<ElementId> ids = uidoc.Selection.GetElementIds(); // 2015

              if( 1 != ids.Count )
              {
            message = "Please select a single element.";
              }
              else
              {
            //ElementSetIterator it = els.ForwardIterator();
            //it.MoveNext();
            //Element e = it.Current as Element; // 2014

            Element e = doc.GetElement( ids.First() ); // 2015

            XYZ p;
            if( !Util.GetElementLocation( out p, e ) )
            {
              message
            = "Selected element has no location defined.";

              Debug.Print( message );
            }
            else
            {
              string msg
            = "Selected element location: "
            + Util.PointString( p );

              XYZ pnp;
              double x, y, pna;

              foreach( ProjectLocation location
            in doc.ProjectLocations )
              {
            ProjectPosition projectPosition
              = location.get_ProjectPosition( XYZ.Zero );

            x = projectPosition.EastWest;
            y = projectPosition.NorthSouth;
            pnp = new XYZ( x, y, 0.0 );
            pna = projectPosition.Angle;

            msg +=
              "\nAngle between project north and true north: "
              + Util.AngleString( pna );

            // Transform tr = Transform.get_Rotation( XYZ.Zero, XYZ.BasisZ, pna ); // 2013
            Transform tr = Transform.CreateRotation( XYZ.BasisZ, pna ); // 2014

            //Transform tt = Transform.get_Translation( pnp ); // 2013
            Transform tt = Transform.CreateTranslation( pnp ); // 2014

            Transform t = tt.Multiply( tr );

            msg +=
              "\nUnrotated element location: "
              + Util.PointString( tr.OfPoint( p ) ) + " "
              + Util.PointString( tt.OfPoint( p ) ) + " "
              + Util.PointString( t.OfPoint( p ) );

            Util.InfoMsg( msg );
              }
            }
              }
              return Result.Failed;
        }
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:98,代码来源:CmdUnrotateNorth.cs


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