Allign annotation flow arrow along the pipe

Hi all
I am trying to create a flow arrow along the direction of pipe in python.I will select the pipe and flow arrow family using select model element and below is the code I am using.
Its creating the flow arrow somewhere but not at the center of pipe along the pipe direction.
can anyone help

Pipe_ = UnwrapElement(IN[0])
ArrowFamily = UnwrapElement(IN[1])

PLoc = Pipe_.Location

PLoc_CP = PLoc.Curve.Evaluate(0.5, True)
Curr_View = doc.ActiveView
PLoc_Curve = Pipe_.Location.Curve
PLoc_Curve_Direction = Pipe_.Location.Curve.Direction


ArrowFamilyTypeId  = ArrowFamily.GetTypeId()
ArrowFamilyType = doc.GetElement(ArrowFamilyTypeId)


#endLoc = end.GetLocation()
#pipe_vector = PLoc_EP.Subtract(PLoc_SP)

NewFlowArrowFamily_Created = doc.Create.NewFamilyInstance(PLoc_CP, ArrowFamilyType, PLoc_Curve_Direction, Curr_View, StructuralType.NonStructural)



TransactionManager.Instance.TransactionTaskDone()
OUT = NewFlowArrowFamily_Created

allign flow arrow.dyn (10.2 KB)

I am trying to implement the solution mentioned in this post in python

The curve direction is going to tell you which direction the pipe was drawn, not the direction of the flow. You need to get the flow direction from the pipe connectors.

If that doesn’t do it for you we’ll need to see the input elements and the output from the python node, plus any errors or warnings that may be presenting.

@Nick_Boyts Got it…I have some plans to use this concept in another logic.
These are the inputs I am giving and its not generating any error

@Nick_Boyts Basically I am trying to place slope arrow along a vector direction at a given point.

Did you change your code to get the flow direction from the pipe connectors? Also, is the origin/orientation of your arrow family in the direction of the arrow?


arrow is created only at the orgin.
This is the arrow family I am using.
it is working fine without the direction using the below code.

NewFlowArrowFamily_Created = doc.Create.NewFamilyInstance(PLoc_CP, ArrowFamilyType, Curr_View)

but obviously arrow is just placed vertically as it is created inside the family.
Annotation Symbol-Plumbing Flow Direction.rfa (384 KB)
my intension is not to get flow from pipe connectors. I want to place arrow in the diection of pipe direction or along the vector created from the start point and end point of pipe curve
pipe_vector = PLoc_EP.Subtract(PLoc_SP)
where
PLoc_EP is end point
PLoc_SP is start point
@Nick_Boyts

Then you need to get the location and direction of the curve and then rotate the arrow to match. If the location seems off, you may have to adjust model coordinates. Dynamo uses the internal (origin) coordinate system, so if your model has been located using a different coordinate system (project or survey) you would need to account for that.

@Nick_Boyts
tried to find angle between Yaxis (Default orientation of flow arrow) and pipe vector .Then tried to rotate location of newly created flow arroe using the below code but getting an error saying expected line got xyz in the rotate method.

def angle_between_vectors(v1, v2):
    dot_product = XYZ.DotProduct(v1, v2)
    mag1 = v1.GetLength()
    mag2 = v2.GetLength()
    cos_angle = dot_product / (mag1 * mag2)
    return math.degrees(math.acos(cos_angle))


Pipe_ = UnwrapElement(IN[0])
ArrowFamily = UnwrapElement(IN[1])

PLoc = Pipe_.Location

#PLoc_CP = PLoc.Curve.Evaluate(0.5, True)



Curr_View = doc.ActiveView
PLoc_Curve = Pipe_.Location.Curve
PLoc_Curve_Direction = Pipe_.Location.Curve.Direction


ArrowFamilyTypeId  = ArrowFamily.GetTypeId()
ArrowFamilyType = doc.GetElement(ArrowFamilyTypeId)

PLoc_CP = PLoc_Curve.Evaluate(0.5, True)
PLoc_SP = PLoc_Curve.Evaluate(0, True)
PLoc_EP = PLoc_Curve.Evaluate(1, True)

pipe_vector = PLoc_EP.Subtract(PLoc_SP)



NewFlowArrowFamily_Created = doc.Create.NewFamilyInstance(PLoc_CP, ArrowFamilyType, Curr_View)
Y_axis = XYZ.BasisY
angle = angle_between_vectors(pipe_vector, Y_axis)

NewFlowArrowFamily_Created.Location.Rotate(pipe_vector, angle)


TransactionManager.Instance.TransactionTaskDone()
OUT = NewFlowArrowFamily_Created

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 145, in
TypeError: expected Line, got XYZ

The Rotate() method requires a line defining the axis of rotation, not just a point. You can use the XYZ you have, extend another point in the Z direction, and use that to create a line.

1 Like

@Nick_Boyts @Thomas_Mahon @c.poupin Can you test this script once. Everything seems fine but arrow family is not getting created . Revit and dynamo file is there in this wetransfer link

TransactionManager.Instance.EnsureInTransaction(doc)








Pipe_ = UnwrapElement(IN[0])
ArrowFamily = UnwrapElement(IN[1])

PLoc = Pipe_.Location

#PLoc_CP = PLoc.Curve.Evaluate(0.5, True)



Curr_View = doc.ActiveView
PLoc_Curve = Pipe_.Location.Curve
PLoc_Curve_Direction = Pipe_.Location.Curve.Direction


ArrowFamilyTypeId  = ArrowFamily.GetTypeId()
ArrowFamilyType = doc.GetElement(ArrowFamilyTypeId)

PLoc_CP = PLoc_Curve.Evaluate(0.5, True)
PLoc_SP = PLoc_Curve.Evaluate(0, True)
PLoc_EP = PLoc_Curve.Evaluate(1, True)




NewFlowArrowFamily_Created = doc.Create.NewFamilyInstance(PLoc_CP, ArrowFamilyType, PLoc_Curve_Direction, doc.ActiveView, StructuralType.NonStructural)

TransactionManager.Instance.TransactionTaskDone()
OUT = NewFlowArrowFamily_Created


trying to implement this

When I check the location of the newly created family getting the origin as output.
(0.000000000, 0.000000000, 0.000000000)

@jobinsunny99…If the arrow is placed somewhere else you can try to get the respective pipe’s center coordinates and again set those coordinates to the arrow family.

Okay.Will try that

Since the arrow is an annotation, I believe that you will need to place it on the sketch plane for the view, otherwise it gets drawn out of range as you are seeing here. Clockwork has some nodes for creating detail components which can serve as the basis of how to do this.

image
this node? @jacob.small

Yes - that would be the one.

1 Like


Filled region Sloped arrow (D).rfa (300 KB)
Now I am using a line based detail item arrow family. This should work right? @jacob.small

Hi @jobinsunny99 …try something here…

1 Like