My First Plugin - Quick modification

My First Plugin - Quick modification

elie.accari
Participant Participant
703 Views
2 Replies
Message 1 of 3

My First Plugin - Quick modification

elie.accari
Participant
Participant

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.

0 Likes
704 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

Dear Elie,

 

Thank you very much for your constructive criticism and extremely helpful advice and suggestions.

 

I will pass them on to my developer support team colleagues and see whether we can find time to update and clarify the samples.

 

I apologise for the current state of affairs there; they really are a bit out of date.

 

Another useful place to get started with Revit development is to follow the hello world samples discussed in the official developer guide:

 

http://help.autodesk.com/view/RVT/2018/ENU/?guid=GUID-93BC4416-FA94-44B3-AA66-931839DA44B4

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 3

jeremytammik
Autodesk
Autodesk

Dear Elie,

 

I published your suggestions here for future reference:

 

http://thebuildingcoder.typepad.com/blog/2017/09/my-first-revit-plugin-enhancements.html

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder