Вопрос

I'm creating an addin for Revit 2014. I want to insert a parallelepiped inside a project, the parallelepiped must have the width, depth, and/or height set during the insertion. I've created a family with a cube of 1x1x1 and 3 instance parameters that automatically resizes the cube accordingly to them values (parameters are named "Width", "Depth", Height").

If I import the family in the drawing and place an instance of it, and AFTER the placement I change the parameter, then the cube is resized correctly.

I wonder if there is a way to resize the cube BEFORE inserting an instance inside the project, I want that the preview under the mouse cursor has the correct size.

I'm using the following instructions in order to place the instance:

Application.ActiveUIDocument.PromptForFamilyInstancePlacement(familySymbol);

Thank you

Это было полезно?

Решение

I agree with everything said above.

Yes, you can only change the family instance dimension parameter values after the instance has been placed.

Yes, you could define different types for different values, and then place the type.

You could create those types on the fly immediately before placing the instance.

In Revit 2015, you can define which family type is placed by PromptForFamilyInstancePlacement.

Where do the width and height etc. come from?

Can you determine them immediately before the call to PromptForFamilyInstancePlacement?

If so, then you could create a new family type with those dimensions on the fly and set that to be the active type right before the call to PromptForFamilyInstancePlacement.

Cheers, Jeremy.

Другие советы

I believe the only solution to resizing the element before placement would be to create different family types for each size you need. Depending on your needs, this may or may not be a practical solution.

The rest of my answer is focused on manipulating the elements after placement.

Do you need your users to be able to select the location of the placement? If not, then you can use the NewFamilyInstance method to place the element (there is no preview, and you must provide a location point).
This function returns the element that was just placed, so you would be able to modify it after placement.
You may be able to use the Selection.PickPoint method to allow the user to pick a point for placement which you can pass to NewFamilyInstance, but I'm not sure how this works with elevations.

The alternative is to use a FilteredElementCollector after the element has been placed. You could use a FamilyInstanceFilter to find all of the instances of the FamilySymbol you are using.
Since Revit ElementId's increase as new elements are placed (with some exceptions due to worksharing/synchronizing that aren't relevant here), you could retrieve the element with the highest ElementId and safely assume that it's the one you just placed.
Another suggestion would be to run the FilteredElementCollector before you place your elements, and then run it again after. The difference would be the element/s that you just placed.

Doesn't the familySymbol object have the get_Parameter() method?

I think you can use it to achieve your goal.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top