Why cant I place detail component by curve?

Well, I have it figured out. Your curve isn’t in the same plane as your view.

Feel free to follow along as I’m going to ‘teach a man to fish’ here so that you and others will be able to solve this stuff more readily in the future. Not all ‘fixes’ are this easy, but the concepts here are good ‘how to’ steps for resolving python based nodes in the future.

Start by opening the DetailComponent.ByCurve node in the Clockwork package (double click on it to do so), select the useful bits (anything that isn’t an input or output node), switch back to the active dyn document and paste them in. You can then remove some of the ‘no longer necessary’ stuff like turn into list, and the like.

Once that was done you can pretty easily see that the issue starts (and continues) with the Python code which @Andreas_Dieckmann was using. Making a few easy edits to it as per this post by @Konrad_K_Sobon will allow us to understand what is going wrong.

Side note, we owe both of these guys some thanks for the accessible content and documentation which they continue to provide the larger community. :smiley:

This was my resulting code, including some markups used to differentiate what I changed.
# Original Code by Andreas Dieckmann
# https://github.com/andydandy74/ClockworkForDynamo
# edited by Jacob Small, following the instructions in this post:
# https://forum.dynamobim.com/t/convert-circuit-path-from-api-to-line/40408/5?u=jacobsmall

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
curves = UnwrapElement(IN[0])
famtype = UnwrapElement(IN[1])
view = UnwrapElement(IN[2])
version = IN[3]
elementlist = list()
counter = 0

TransactionManager.Instance.EnsureInTransaction(doc)
for curve in curves:
if version > 2015:
if not(famtype.IsActive): famtype.Activate()
try:
# added line to set error report to none if there is no failure.
errorReport = None
newobj = doc.Create.NewFamilyInstance(curve.ToRevitType(),famtype,view)
elementlist.append(newobj.ToDSType(False))
except:
# revised except lines to import the traceback and set the error report acordingly.
import traceback
errorReport = traceback.format_exc()

TransactionManager.Instance.TransactionTaskDone()
# updated the output to include a list of the elements and the traceback
OUT = [elementlist,errorReport]

That edit allows access to the resulting element list, as well as the error report for anything which fails in the output results. Reviewing that error report, the reason behind the failureis pretty straight forward:

Traceback (most recent call last): File "<string>", line 30, in <module> Exception: The line is not in the plane of view. Parameter name: line

With that bit of knowledge, it’s pretty clear what you have to do: move the curve onto the same plane as the view. From here on out this is basic Dynamo, just a matter of finding the right nodes.

Fortunately we have a handy node also in the Clockwork package that we can leverage to find out what plane the linework needs to be on: the View.Plane node. There is also and an out of the box node called Curve.PullOntoPlane which will adjust the curve geometry and location as needed. Your actual use case may require a few tweaks to stuff like list lacing and levels.

From there things should just work with the old node, no edits required and you don’t even have to make a new custom node, or maintain the python in the .dyn.

I’ll make an issue on the Clockwork package’s GitHub repo tomorrow, which will included the code above so that if he thinks that it would be worthwhile then Andreas can update the package to include that error handling.

7 Likes