Convert Circuit Path from API to line

Hello,

I was able to capture the path of a circuit in Revit. Now I want to convert this data to line and insert a family of Detail Line. But look what is written in Revit API 2018

"The list of the electrical system circuit path node position is not valid. The length of the list should be more than one, the first node should be the position of the panel where the circuit begins at, the adjacent nodes should not be too close , and should be on the same level or on the same vertical line, to keep each segment of the circuit path always horizontal or vertical Also note that the first node position should be the position of the connector (the one connects to the circuit) of the panel, but not the origin of the panel instance. "

Code - GET CIRCUIT PATH

Now the problem is, I can’t use this data to convert in points and then line.

There is the SetCircuitPath api but I can’t use it either. Does anyone have a tip in this regard?

Get rid of your try except and you will see an exception and might even be able to resolve this yourself…never use try except indiscriminately otherwise all you end up doing is sweeping your problems under the carpet ‘so-to-speak’, and suppressing otherwise useful exception messages which hinders your ability to debug - its one of the worst habits I’ve seen emerging in the Dynamo community. My advice; never use try catch unless you’ve exhausted every other option.

3 Likes

TKS Thomas!

:clap:

2 Likes

I am not sure I would say “never”. I would probably say, if you will use try and except then at least use some sort of logging to output the error:

try:
    errorReport = None
except:
    import traceback
    errorReport = traceback.format_exc()

if None == errorReport:
    OUT = 0
else:
    OUT = errorReport

I did caveat that with “never use try catch unless you’ve exhausted every other option” so we are in agreement. And sure - just don’t use try except as ‘fix-all’, or for flow control in general, especially when other statements are more appropriate and don’t carry the overhead nor suppress useful exceptions. It sets a bad precedent if developers don’t learn why allowing exceptions to occur is so useful. My point is to use try except only when there is no other option, not as a default go-to :+1:

1 Like