0

In Revit I have a sweep element inside a family and I would like to set its work plane programmatically.

Inside Revit I can achieve that by double-clicking my family and then select the sweep and click Edit Work Plane. Here I can choose any named reference plane to be the work plane.

How would I do that using the revit API? The only entry associated with work planes I can find is the GetOrderedParameters() method where one of its names is Work Plane.

Update

What I found out so far is this:

var parameter = sweep.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM);
parameter.Set("new parameter value");

But the SKETCH_PLANE_PARAM parameter is read only. Is there a way to set it using another way?

1 Answers1

0

So, I'm not aware of a way to set the workplane to a named workplane offhand (I'm sure there's a way, I just can't think of it at the moment). But based on what you've got so far what you can do is find out the height of the named workplane you're referring to and then use the code below:

        using (Transaction trans = new Transaction(CurrentDocument, "Setting the workplane..."))
        {
            Parameter sketchPlane = sweep.get_Parameter(BuiltInParameter.SKETCH_PLANE_PARAM);

            // do whatever modifications you need to do to the parameter

            sweep.ParametersMap.set_Item("SKETCH_PLANE_PARAM", sketchPlane);

            trans.Commit();
        }
prestonsmith
  • 758
  • 1
  • 9
  • 29
  • That's the same way I tried to approach this problem but it doesn't work since `SKETCH_PLANE_PARAM` is read-only –  Aug 15 '16 at 07:31
  • @MikeDelta - you sure you tried the sweep.ParametersMaps.set_item() method? In either case, I'll try and take a look again when I get home tonight – prestonsmith Aug 15 '16 at 18:30