My First Plugin - Quick modification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I refer to the high entropy body of knowledge in My First Plugin: http://www.autodesk.com/myfirstrevitplugin
Another thread is dealing with issues some users are facing getting the plugin to work.
The above linked page includes a feedback email which has bounced back ("myfirstplugin wasn't found at autodesk.com"), so I am posting here in case new users seek to implement the same modification.
Issue #1: location of the plugin
Not all users have access to the addins folder in Program Files, but all users have access to the %AppData%\Roaming\Autodesk\Revit\addins\<version> folder. If this is mentioned in the tutorial it can reduce the number of questions asked.
Issue #2: unfamiliar behavior
The code does not properly copy the group. It just places it where you click, which could be in the middle of the other room. A more familiar way is to do a Copy From: To:. Only 3 lines of code including 2 modifications are required.
Modification #1: Pick 2 points and calculate the distance between the two, instead of picking only 1 point
To do so, replace the following code in the original lesson:
//Pick a point XYZ point = sel.PickPoint("Please pick a point to place group");
with the following:
//Pick a point XYZ pointFrom = sel.PickPoint("Pick a point to copy From"); XYZ pointTo = sel.PickPoint("Pick a point to copy To"); //Calculate the distance between the two points XYZ ptDist = pointTo - pointFrom;
Modification #2: Use the Copy method instead of Place
Replace the following line which falls between the trans.Srtat and trans.Commit lines:
doc.Create.PlaceGroup(point, group.GroupType);
With this line:
ElementTransformUtils.CopyElement(doc, elem.Id, ptDist);
Finally, a suggestion: the text seem to entice Revit users into programming. In this regard, I would consider doing the following:
Add Lesson 0 (or renumber the lessons): Implement the same code in a macro using the Edit / SharpDevelop ready accessible from inside Revit, without going to MS Visual Studio.
Then Lesson 1 could become: Now let's do this again by converting this macro into an add-in.