-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
published 1602_place_famil_instance.md
- Loading branch information
1 parent
4f64643
commit 6e299e9
Showing
7 changed files
with
309 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<p><head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<link rel="stylesheet" type="text/css" href="bc.css"> | ||
<!-- | ||
<script src="run_prettify.js" type="text/javascript"></script> | ||
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js" type="text/javascript"></script> | ||
--> | ||
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js" type="text/javascript"></script> | ||
</head></p> | ||
<!--- | ||
- migrate from 2014 to 2018 | ||
`FamilySymbolSet` no longer exists, use generic collection of element ids instead, `ISet<ElementId>`. | ||
`Family.Symbols` no longer exists, use `GetFamilySymbolIds` instead. | ||
http://thebuildingcoder.typepad.com/blog/2013/10/text-file-driven-automatic-placement-of-family-instances.html#comment-3619372844 | ||
Campbell says: | ||
I'm trying to get this to work In revit 2016 however FamilySymbolSet was removed in 2016. Is there a workaround to get the plug in on this page to work without it. I can get the form to populate with families, but not show the types when i select one | ||
Renzo adds: | ||
could you find the solution? | ||
That is quite easy... | ||
I migrated the add-in to Revit 2018. | ||
#RevitAPI @AutodeskRevit #bim #dynamobim @AutodeskForge #ForgeDevCon | ||
Migrating a Revit add-in to a new release of the Revit API is generally very easy. | ||
The API features slight changes from version to version. | ||
Modifications are announced a year or two in advance, and signalled during compilation by deprecated API usage warnings. | ||
If you clean up your code every year or two and remove all API usage that causes warning messages, you will normally have very little to do to migrate it later on... | ||
---> | ||
|
||
<h3>Migrating PlaceInstances to Revit 2018</h3> | ||
<p>Migrating a Revit add-in to a new release of the Revit API is generally very easy.</p> | ||
<p>The API features slight changes from version to version.</p> | ||
<p>Modifications are announced a year or two in advance, and signalled during compilation by deprecated API usage warnings.</p> | ||
<p>If you clean up your code every year or two and remove all API usage that causes warning messages, you will normally have very little to do to migrate it later on.</p> | ||
<p>If you run into any problems, just search the documentation on <em>What's New in the Revit API</em>; most modifications are listed there, including instructions on how to update the code to handle them:</p> | ||
<ul> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2013/02/whats-new-in-the-revit-2010-api.html">What's New in the Revit 2010 API</a></li> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2013/02/whats-new-in-the-revit-2011-api.html">What's New in the Revit 2011 API</a></li> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2013/02/whats-new-in-the-revit-2012-api.html">What's New in the Revit 2012 API</a></li> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2013/03/whats-new-in-the-revit-2013-api.html">What's New in the Revit 2013 API</a></li> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2013/04/whats-new-in-the-revit-2014-api.html">What's New in the Revit 2014 API</a></li> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2014/04/whats-new-in-the-revit-2015-api.html">What's New in the Revit 2015 API</a></li> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2015/04/whats-new-in-the-revit-2016-api.html">What's New in the Revit 2016 API</a></li> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2016/04/whats-new-in-the-revit-2017-api.html">What's New in the Revit 2017 API</a></li> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2016/11/whats-new-in-the-revit-20171-api.html">What's New in the Revit 2017.1 API</a></li> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2017/04/whats-new-in-the-revit-2018-api.html">What's New in the Revit 2018 API</a></li> | ||
<li>Revit 2018.1 API:<ul> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2017/08/revit-20181-and-the-visual-materials-api.html">Revit 2018.1 and the Visual Materials API</a></li> | ||
<li><a href="http://thebuildingcoder.typepad.com/blog/2017/09/revit-201811-fixes-cropbox-setting.html">Revit 2018.1.1 API documentation</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
<p>As an example, let's look at the migration of | ||
the <a href="http://thebuildingcoder.typepad.com/blog/2013/10/text-file-driven-automatic-placement-of-family-instances.html">PlaceInstances add-in implementing text file driven automatic placement of family instances</a> from | ||
Revit 2014 to Revit 2018, prompted | ||
by <a href="http://thebuildingcoder.typepad.com/blog/2013/10/text-file-driven-automatic-placement-of-family-instances.html#comment-3619372844">two comments</a> by | ||
Campbell and Renzo:</p> | ||
<p><strong>Question:</strong></p> | ||
<blockquote> | ||
<p>I'm trying to get this to work in Revit 2016; however, <code>FamilySymbolSet</code> was removed in 2016. | ||
Is there a workaround to get the plug in on this page to work without it? | ||
I can get the form to populate with families, but not show the types when I select one...</p> | ||
<p>Could you find the solution?</p> | ||
</blockquote> | ||
<p><strong>Answer:</strong> Yes, this is easy.</p> | ||
<p>The class <code>FamilySymbolSet</code> no longer exists; use a generic collection of element ids instead, in this case, <code>ISet<ElementId></code>.</p> | ||
<p>The property <code>Family.Symbols</code> no longer exists; use <code>GetFamilySymbolIds</code> instead.</p> | ||
<p>I first performed a flat migration from the Revit 2014 API to Revit 2018, sinply updating the license year, .NET build target version and Revit API DLL references.</p> | ||
<p>That causes the following errors and warnings:</p> | ||
<pre> | ||
------ Rebuild All started: Project: PlaceInstances, Configuration: Debug Any CPU ------ | ||
|
||
error CS0246: The type or namespace name 'FamilySymbolSet' could not be found (are you missing a using directive or an assembly reference?) | ||
|
||
error CS1061: 'Family' does not contain a definition for 'Symbols' and no extension method 'Symbols' accepting a first argument of type 'Family' could be found (are you missing a using directive or an assembly reference?) | ||
|
||
warning CS0162: Unreachable code detected | ||
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== | ||
</pre> | ||
|
||
<p>The warning message is intentional.</p> | ||
<p>The Revit 2014 code causing the two errors looks like this:</p> | ||
<pre class="code"> | ||
<span style="color:#2b91af;">FamilySymbolSet</span> symbols = f.Symbols; | ||
|
||
<span style="color:green;">// I have to convert the FamilySymbolSet to a</span> | ||
<span style="color:green;">// List, or the DataSource assignment will throw </span> | ||
<span style="color:green;">// an exception saying "Complex DataBinding </span> | ||
<span style="color:green;">// accepts as a data source either an IList or</span> | ||
<span style="color:green;">// an IListSource.</span> | ||
|
||
<span style="color:#2b91af;">List</span><<span style="color:#2b91af;">FamilySymbol</span>> symbols2 | ||
= <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span><<span style="color:#2b91af;">FamilySymbol</span>>( | ||
symbols.Cast<<span style="color:#2b91af;">FamilySymbol</span>>() ); | ||
</pre> | ||
|
||
<p>I converted it to compile for Revit 2018 like this:</p> | ||
<pre class="code"> | ||
<span style="color:#2b91af;">ISet</span><<span style="color:#2b91af;">ElementId</span>> ids = f.GetFamilySymbolIds(); | ||
|
||
<span style="color:#2b91af;">Document</span> doc = f.Document; | ||
|
||
<span style="color:#2b91af;">List</span><<span style="color:#2b91af;">FamilySymbol</span>> symbols2 | ||
= <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span><<span style="color:#2b91af;">FamilySymbol</span>>( | ||
ids.Select<<span style="color:#2b91af;">ElementId</span>, <span style="color:#2b91af;">FamilySymbol</span>>( id | ||
=> doc.GetElement( id ) <span style="color:blue;">as</span> <span style="color:#2b91af;">FamilySymbol</span> ) ); | ||
</pre> | ||
|
||
<p>The update is provided in | ||
the <a href="https://github.com/jeremytammik/PlaceInstances">PlaceInstances GitHub repository</a> | ||
in <a href="https://github.com/jeremytammik/PlaceInstances/releases/tag/2018.0.0.0">release 2018.0.0.0</a>.</p> | ||
<p>You can check out the changes I made in | ||
the <a href="https://github.com/jeremytammik/PlaceInstances/compare/2014.0.0.7...2018.0.0.0">diff to the preceding version</a>.</p> | ||
<p>For the sake of completeness, here are | ||
the <a href="zip/2018_placeinstances_01.txt">error lists before and after the fix</a>.</p> | ||
<p>I hope this helps.</p> | ||
<p><center> | ||
<img src="img/migration.png" alt="Migration" width="160"/> | ||
</center></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<link rel="stylesheet" type="text/css" href="bc.css"> | ||
<!-- | ||
<script src="run_prettify.js" type="text/javascript"></script> | ||
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js" type="text/javascript"></script> | ||
--> | ||
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js" type="text/javascript"></script> | ||
</head> | ||
|
||
<!--- | ||
- migrate from 2014 to 2018 | ||
`FamilySymbolSet` no longer exists, use generic collection of element ids instead, `ISet<ElementId>`. | ||
`Family.Symbols` no longer exists, use `GetFamilySymbolIds` instead. | ||
http://thebuildingcoder.typepad.com/blog/2013/10/text-file-driven-automatic-placement-of-family-instances.html#comment-3619372844 | ||
Campbell says: | ||
I'm trying to get this to work In revit 2016 however FamilySymbolSet was removed in 2016. Is there a workaround to get the plug in on this page to work without it. I can get the form to populate with families, but not show the types when i select one | ||
Renzo adds: | ||
could you find the solution? | ||
That is quite easy... | ||
I migrated the add-in to Revit 2018. | ||
#RevitAPI @AutodeskRevit #bim #dynamobim @AutodeskForge #ForgeDevCon | ||
Migrating a Revit add-in to a new release of the Revit API is generally very easy. | ||
The API features slight changes from version to version. | ||
Modifications are announced a year or two in advance, and signalled during compilation by deprecated API usage warnings. | ||
If you clean up your code every year or two and remove all API usage that causes warning messages, you will normally have very little to do to migrate it later on... | ||
---> | ||
|
||
### Migrating PlaceInstances to Revit 2018 | ||
|
||
Migrating a Revit add-in to a new release of the Revit API is generally very easy. | ||
|
||
The API features slight changes from version to version. | ||
|
||
Modifications are announced a year or two in advance, and signalled during compilation by deprecated API usage warnings. | ||
|
||
If you clean up your code every year or two and remove all API usage that causes warning messages, you will normally have very little to do to migrate it later on. | ||
|
||
If you run into any problems, just search the documentation on *What's New in the Revit API*; most modifications are listed there, including instructions on how to update the code to handle them: | ||
|
||
- [What's New in the Revit 2010 API](http://thebuildingcoder.typepad.com/blog/2013/02/whats-new-in-the-revit-2010-api.html) | ||
- [What's New in the Revit 2011 API](http://thebuildingcoder.typepad.com/blog/2013/02/whats-new-in-the-revit-2011-api.html) | ||
- [What's New in the Revit 2012 API](http://thebuildingcoder.typepad.com/blog/2013/02/whats-new-in-the-revit-2012-api.html) | ||
- [What's New in the Revit 2013 API](http://thebuildingcoder.typepad.com/blog/2013/03/whats-new-in-the-revit-2013-api.html) | ||
- [What's New in the Revit 2014 API](http://thebuildingcoder.typepad.com/blog/2013/04/whats-new-in-the-revit-2014-api.html) | ||
- [What's New in the Revit 2015 API](http://thebuildingcoder.typepad.com/blog/2014/04/whats-new-in-the-revit-2015-api.html) | ||
- [What's New in the Revit 2016 API](http://thebuildingcoder.typepad.com/blog/2015/04/whats-new-in-the-revit-2016-api.html) | ||
- [What's New in the Revit 2017 API](http://thebuildingcoder.typepad.com/blog/2016/04/whats-new-in-the-revit-2017-api.html) | ||
- [What's New in the Revit 2017.1 API](http://thebuildingcoder.typepad.com/blog/2016/11/whats-new-in-the-revit-20171-api.html) | ||
- [What's New in the Revit 2018 API](http://thebuildingcoder.typepad.com/blog/2017/04/whats-new-in-the-revit-2018-api.html) | ||
- Revit 2018.1 API: | ||
- [Revit 2018.1 and the Visual Materials API](http://thebuildingcoder.typepad.com/blog/2017/08/revit-20181-and-the-visual-materials-api.html) | ||
- [Revit 2018.1.1 API documentation](http://thebuildingcoder.typepad.com/blog/2017/09/revit-201811-fixes-cropbox-setting.html) | ||
|
||
As an example, let's look at the migration of | ||
the [PlaceInstances add-in implementing text file driven automatic placement of family instances](http://thebuildingcoder.typepad.com/blog/2013/10/text-file-driven-automatic-placement-of-family-instances.html) from | ||
Revit 2014 to Revit 2018, prompted | ||
by [two comments](http://thebuildingcoder.typepad.com/blog/2013/10/text-file-driven-automatic-placement-of-family-instances.html#comment-3619372844) by | ||
Campbell and Renzo: | ||
|
||
**Question:** | ||
|
||
> I'm trying to get this to work in Revit 2016; however, `FamilySymbolSet` was removed in 2016. | ||
Is there a workaround to get the plug in on this page to work without it? | ||
I can get the form to populate with families, but not show the types when I select one... | ||
|
||
> Could you find the solution? | ||
**Answer:** Yes, this is easy. | ||
|
||
The class `FamilySymbolSet` no longer exists; use a generic collection of element ids instead, in this case, <code>ISet<ElementId></code>. | ||
|
||
The property `Family.Symbols` no longer exists; use `GetFamilySymbolIds` instead. | ||
|
||
I first performed a flat migration from the Revit 2014 API to Revit 2018, sinply updating the license year, .NET build target version and Revit API DLL references. | ||
|
||
That causes the following errors and warnings: | ||
|
||
<pre> | ||
------ Rebuild All started: Project: PlaceInstances, Configuration: Debug Any CPU ------ | ||
|
||
error CS0246: The type or namespace name 'FamilySymbolSet' could not be found (are you missing a using directive or an assembly reference?) | ||
|
||
error CS1061: 'Family' does not contain a definition for 'Symbols' and no extension method 'Symbols' accepting a first argument of type 'Family' could be found (are you missing a using directive or an assembly reference?) | ||
|
||
warning CS0162: Unreachable code detected | ||
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ========== | ||
</pre> | ||
|
||
The warning message is intentional. | ||
|
||
The Revit 2014 code causing the two errors looks like this: | ||
|
||
<pre class="code"> | ||
<span style="color:#2b91af;">FamilySymbolSet</span> symbols = f.Symbols; | ||
|
||
<span style="color:green;">// I have to convert the FamilySymbolSet to a</span> | ||
<span style="color:green;">// List, or the DataSource assignment will throw </span> | ||
<span style="color:green;">// an exception saying "Complex DataBinding </span> | ||
<span style="color:green;">// accepts as a data source either an IList or</span> | ||
<span style="color:green;">// an IListSource.</span> | ||
|
||
<span style="color:#2b91af;">List</span><<span style="color:#2b91af;">FamilySymbol</span>> symbols2 | ||
= <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span><<span style="color:#2b91af;">FamilySymbol</span>>( | ||
symbols.Cast<<span style="color:#2b91af;">FamilySymbol</span>>() ); | ||
</pre> | ||
|
||
I converted it to compile for Revit 2018 like this: | ||
|
||
<pre class="code"> | ||
<span style="color:#2b91af;">ISet</span><<span style="color:#2b91af;">ElementId</span>> ids = f.GetFamilySymbolIds(); | ||
|
||
<span style="color:#2b91af;">Document</span> doc = f.Document; | ||
|
||
<span style="color:#2b91af;">List</span><<span style="color:#2b91af;">FamilySymbol</span>> symbols2 | ||
= <span style="color:blue;">new</span> <span style="color:#2b91af;">List</span><<span style="color:#2b91af;">FamilySymbol</span>>( | ||
ids.Select<<span style="color:#2b91af;">ElementId</span>, <span style="color:#2b91af;">FamilySymbol</span>>( id | ||
=> doc.GetElement( id ) <span style="color:blue;">as</span> <span style="color:#2b91af;">FamilySymbol</span> ) ); | ||
</pre> | ||
|
||
The update is provided in | ||
the [PlaceInstances GitHub repository](https://github.com/jeremytammik/PlaceInstances) | ||
in [release 2018.0.0.0](https://github.com/jeremytammik/PlaceInstances/releases/tag/2018.0.0.0). | ||
|
||
You can check out the changes I made in | ||
the [diff to the preceding version](https://github.com/jeremytammik/PlaceInstances/compare/2014.0.0.7...2018.0.0.0). | ||
|
||
For the sake of completeness, here are | ||
the [error lists before and after the fix](zip/2018_placeinstances_01.txt). | ||
|
||
I hope this helps. | ||
|
||
<center> | ||
<img src="img/migration.png" alt="Migration" width="160"/> | ||
</center> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.