Drag and Drop - Add Family Parameters

Drag and Drop - Add Family Parameters

coopgodd
Contributor Contributor
1,194 Views
4 Replies
Message 1 of 5

Drag and Drop - Add Family Parameters

coopgodd
Contributor
Contributor

Hey everyone,

I have recently added a drag and drop system into my application and I'm looking to immediately add some parameters to the element I'm dropping into the model. However, I can't find a solid and straight forward way to do this.

Here is the code I have right now (where chair.File is a string path to the file itself):

List<String> data = new List<String>();
data.Add(chair.File);
UIApplication.DoDragDrop(data);

 What I need to do I add a parameter (like an ID) so that when I connect it to my database I'm able to easily communicate back and forth for other data. Any thoughts on the best way to do this? One of my biggest issues right now is actually getting the object I've just dropped in to save the element or element ID in a variable within my code! So that would be my most pressing question.

 

Thanks!

Accepted solutions (1)
1,195 Views
4 Replies
Replies (4)
Message 2 of 5

RPTHOMAS108
Mentor
Mentor
Accepted solution

Why not use DoDragDrop(Object, IDropHandler)

 

Then place the family and update the parameter in the execute method on IDropHandler. In reality you should probably implement IControllableDropHandler.

 

I think what you are using instead is just doing things the way Revit would with that kind of operation by default.

Message 3 of 5

coopgodd
Contributor
Contributor

Thanks for the response! I do have this implemented later in the project, so I'm sure I can craft a way to do it for my specific circumstances.

 

I appreciate the response!

0 Likes
Message 4 of 5

coopgodd
Contributor
Contributor

There is an issue with this approach because I am getting the data for the object from an external file. 

Would you or anyone else have any ideas as to how to extract the object data from a file? Otherwise, I can use a handler but it won't do anything!

 

Thanks!

0 Likes
Message 5 of 5

RPTHOMAS108
Mentor
Mentor

Probably your best option is to implement an IUpdater that Executes in response to the items being added to the document and then updates their parameters.

 

I assume you are dropping rfa files?

 

If you are dragging groups of these, then you need a key to identify that newly created instance in the document so the updater knows what to do with it. However that is easy: you can only at one point in time drag a group of files where each is a different rfa. It isn't possible to drag the same rfa to two locations for one drop so all you really need to do is identify each created item by family name etc. that will then link to what parameters need to be assigned for it in that instance in time. Also the reality is that if you drag more than one file it will add the families but not prompt for instance placement (just adding types).

 

 

0 Likes