Curve.PullOntoPlane using python?


can we achieve the function of this node using python and revit API?

Dynamo API should do the trick just fine. Any reason you’re sticking to Revit API?

Trying to create an addin in pyrevit.

I guess it’s best to ask on that forum then. I also recall that the PyRevit add-in does allow executing a Dynamo graph, so you may be spending some time reworking the code base for very little functional benefit.

Okay.Noted.Any hints you can provide from revit API?. I think there are methods to project a point to a plane in revit API.

There isn’t an explicit method for plane-curve projection in the API, but this approach simulates it:

@jacob.small always best to minimize application dependencies, so targeting the Revit API is best, plus its faster.

3 Likes

Thanks

Getting an error saying
TypeError: expected ModelCurve, got Line

while adding curve to model curve array

#Getting pipe and its location curve
Pipe_ = UnwrapElement(IN[0])
PLoc_Curve = Pipe_.Location.Curve


#creating plane from current view
Curr_View = doc.ActiveView
view_dir = Curr_View.ViewDirection
origin = Curr_View.Origin

# Construct a Plane object from the view's direction and origin
plane = Plane.CreateByNormalAndOrigin(view_dir, origin)

model_curve_array = ModelCurveArray()
model_curve_array.append(PLoc_Curve)
doc.ConvertModelToDetailCurves(Curr_View,model_curve_array)
	

Revit API reference

image

This is the solution mentioned in the post

Agreed in general, but not sure it’s as concerning in this case.

  • The time savings is likely minimal until you break the memory limit at which point both will struggle due to the looping methods I’m guessing are present at such a scale in the python node.
  • The lack of a direct means to accomplish in the Revit API and things get slow to begin with. Jeremy mentions that his experiments with this likely involve tessellating the geometry (slow an less accurate) or an external library (ie: Dynamo).
  • The other method of creating detail curves would add an additional item to the database which while we could roll back would likely moot any time savings found, and may also require creating the model curve to begin with (unclear what the source geometery is).
  • Last I checked PyRevit includes the Dynamo library and loads it when you start Revit, and so you’re already incorporating that dependency in the project sense; granted this could change but so could the Revit API.

Updated code .Its able to create a detail curve

#Getting pipe and its location curve
Pipe_ = UnwrapElement(IN[0])
PLoc_Curve = Pipe_.Location.Curve


#creating plane from current view
Curr_View = doc.ActiveView
view_dir = Curr_View.ViewDirection
origin = Curr_View.Origin

# Construct a Plane object from the view's direction and origin
plane = Plane.CreateByNormalAndOrigin(view_dir, origin)

s_p = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(doc.ActiveView.ViewDirection, PLoc_Curve.GetEndPoint(0)))

m_c = doc.Create.NewModelCurve(PLoc_Curve,s_p)


# Create a list to hold the detail curves




model_curve_array = ModelCurveArray()
model_curve_array.Append(m_c)

Detail_Curve = doc.ConvertModelToDetailCurves(Curr_View,model_curve_array)
TransactionManager.Instance.TransactionTaskDone()
OUT =Detail_Curve

I’m guessing this is linked to your pipe slope issue? If so you have a possible solution in grabbing the start and end point of the location curve, Pull the X and Y values, and rebuild the point with those and the elevation of the view’s plane.

1 Like

This worked.Thanks