Python expected xyz got line and Door trim width type parameter


#1

Hi guys, now I stuck in python script for Revit. I want to create the beam by this syntax:
doc.Create.NewFamilyInstance(curve, family symbol, level, Structure Type)
but when I collect all the detail line in the active View and put it there in the syntax, it pop up the error (Expected XYZ got line). I did try to use curve.GeometryCurve but it didn’t work out. So how can I get the curve out of the detail line in the project ?

And for Door Trim Width parameter, how can I get it because I try to use with door.LookupParameter(“Trim Width”) but it didn’t work out also. Then I can not use get BuiltInParameter since there is no name for “Door Trim Width” in BuiliIn Category list.

I am really appreciate any helps.
Thank you very much.


#2

Hey,

Apologies I’m away from my PC…

So just to start you off, I think you’re getting the funny error because you aren’t giving a curve (I would try and extract the curve from the detail line) so it doesn’t know which creation method you were trying and presumes one which needed an XYZ.

It would be easier if you could post (or post a link to) the files you’re having problems with…

I’ve never used a door trim width parameter… there’s a node for getting all element parameters… if it’s an instance parameter and you’re trying to get it from a family type you’ll get an error… but as you can tell I’m guessing wildly :smiley:

Hope that helps,

Mark


#3

This script works perfectly when I get the start point and end point of the detail and using createbound method to create the curve out of it. But one problem it only works when the beam is straight, not for the curve beam.
When I put the line from UnwrapElement([0]) directly to the beam = doc.Create.NewFamilyInstance method, it pop up the warning that “expected XYZ got line”, even if I try to use line.GeometryCurve.

Thank you for you time.
Best regards.


#5

It do have the curve method for Create.NewFamilyInstance not only XYZ. Please refer to this one:
http://www.revitapidocs.com/2018.1/d8e0a91a-b062-3a86-6d8e-779534459ff4.htm

And if you take a look and my script above, I used curve not XYZ.

Thank you,
Best regards.


#6

Ah my mistake, I somehow missed that one. Sorry.

Can you show the full Dynamo with outputs and the full error? It would help to see what line the error is on.


#7

Hmm… I’m getting something odd happening…

So you can see my point about feeding the geometry.

You can see that it works with the OOTB node.

But also, you can see that it’s failing with the Clockwork node that uses the same method as you were trying.

I tried on 1.3 and 2 and get the same quirk… I also tried with a wall location line instead of the line geometry from a detail line.

This is line 29…

image

Maybe I’m doing something wrong… @Andreas_Dieckmann would you mind helping?

Cheers,

Mark

Edit: This may be useful https://github.com/DynamoDS/DynamoRevit/blob/4cc183fb6eb7db13e29cf2d04192df499961a8b9/src/Libraries/RevitNodes/Elements/StucturalFraming.cs#L189


#8

Can you upload your full script code ? So that I can see what part is having problem ?

Thank you.


#9

Sorry for not being clear, I just copied the python out of the Clockwork node to see what was going on…

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])
lvl = UnwrapElement(IN[2])
elementlist = list()
counter = 0

TransactionManager.Instance.EnsureInTransaction(doc)
# make sure familysymbol is active
if famtype.IsActive == False:
famtype.Activate()
doc.Regenerate()
for curve in curves:
newobj = doc.Create.NewFamilyInstance(curve.ToRevitType(),famtype,lvl,Structure.StructuralType.NonStructural)
elementlist.append(newobj.ToDSType(False))
TransactionManager.Instance.TransactionTaskDone()
OUT = elementlist