Skip to content

Commit

Permalink
in EditFilledRegion: foreach iter, using tx, single tx, XYZ static me…
Browse files Browse the repository at this point in the history
…mber
  • Loading branch information
Jeremy Tammik committed Sep 4, 2015
1 parent e0c2ff1 commit 9b423a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
27 changes: 14 additions & 13 deletions BuildingCoder/BuildingCoder/CmdFilledRegionCoords.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,22 @@ class CmdFilledRegionCoords : IExternalCommand
/// deleting the line style. From:
/// http://forums.autodesk.com/t5/revit-api/filled-region/td-p/5796463
/// </summary>
public void EditFilledRegion( Document doc, UIDocument uidoc )
public void EditFilledRegion( Document doc )
{
FilteredElementCollector fillRegionTypes = new FilteredElementCollector( doc ).OfClass( typeof( FilledRegion ) );
FilteredElementIterator itr = fillRegionTypes.GetElementIterator();
while( itr.MoveNext() )
FilteredElementCollector fillRegions
= new FilteredElementCollector( doc )
.OfClass( typeof( FilledRegion ) );

using( Transaction tx = new Transaction( doc ) )
{
Element element = (Element) itr.Current;
FilledRegion filledRegion = doc.GetElement( element.Id ) as FilledRegion;

Transaction tx = new Transaction( doc );
tx.Start( "move" );
XYZ xyznew = new XYZ( 1, 0, 0 );
XYZ xyzOld = new XYZ( -1, 0, 0 );
ElementTransformUtils.MoveElement( doc, filledRegion.Id, xyznew );
ElementTransformUtils.MoveElement( doc, filledRegion.Id, xyzOld );
tx.Start( "Move all Filled Regions" );

foreach( FilledRegion filledRegion in fillRegions )
{
XYZ v = XYZ.BasisX;
ElementTransformUtils.MoveElement( doc, filledRegion.Id, v );
ElementTransformUtils.MoveElement( doc, filledRegion.Id, -v );
}
tx.Commit();
}
}
Expand Down
1 change: 1 addition & 0 deletions BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
// 2015-08-18 2016.0.120.8 replaced obsolete PlanarFace.Normal property by PlanarFace.FaceNormal
// 2015-08-18 2016.0.120.9 eliminated obsolete API calls to ElementTransformUtils.MirrorElements by adding bool mirrorCopies argument
// 2015-09-04 2016.0.120.10 added original EditFilledRegion to show code improvements
// 2015-09-04 2016.0.120.11 in EditFilledRegion: foreach iter, using tx, single tx, XYZ static member
//
[assembly: AssemblyVersion( "2016.0.120.10" )]
[assembly: AssemblyFileVersion( "2016.0.120.10" )]

0 comments on commit 9b423a5

Please sign in to comment.