Hi everyone, I am trying to write a Python script to place family according to Duct element including the rotation of the duct. But I am not success to get the angle between the duct and the coordinate system.
Can anyone advise me how can I place family which align the duct element?
Hello why not just get the duct direction and a angle about axis and then just rotate
Hi Sovitek, do you mean get the direction from duct.locationcurve? Could you explain more how to get the correct angle to rotate the new placed family?
More information is duct should be vertical
Use Duct Surfaces References from GeniusLoci package. Select top duct’s surface and get its normal. And use angle between needed vectors at last.
Hi Vladimir, is it also work for revit api?
Just check it by yourself.
Hi,
A solution using the coordinate system of connectors
import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
#Preparing input from dynamo to revit
elem = UnwrapElement(IN[0])
connectorEnd = sorted(elem.ConnectorManager.Connectors, key = lambda c : c.Origin.DistanceTo(elem.Location.Curve.GetEndPoint(0)))[0]
con_system = connectorEnd.CoordinateSystem
OUT = CoordinateSystem.ByOriginVectors(connectorEnd.Origin.ToPoint(),
con_system.BasisX.ToVector(),
con_system.BasisY.ToVector(),
con_system.BasisZ.ToVector())
2 Likes
Hi c.poupin, this is exact solution for my case.
Many Thanks.!