DynamoRevit
DynamoRevit copied to clipboard
Method ToRevitType() fails converting curves - Dynamo 2.3.0.5885
Issue Description
Method ToRevitType() failed converting curves
What did you do?
Trying to convert curves with ToRevitType() method in order to create walls. This curves are derived from Rooms.
The process I used:
First I joined the Room curves with Polycurve.ByJoinedCurves node, in order to apply an offset.
After that I used Geometry.Explode node to recover the curves
So, I apllied ToRevitType() method and its fails
Excerpt from my python script that contains walls creation `
# Force close Dynamo transaction
TransactionManager.Instance.ForceCloseTransaction()
# transaction
with Transaction(doc) as t:
t.Start("awtools Walls Create")
for curves, wallType, level, height in zip(roomCurves, wallTypes, levels, heights):
if curves == [] or curves == None:
continue
curvesAsRevitTypes = [crv.ToRevitType() for crv in curves]
for c in curvesAsRevitTypes:
try:
heightFeet = UnitsConvertionTools().LengthDisplayUnitsToInternal(doc, height)
newWall = Wall.Create(doc, c, wallType.Id, level.Id, heightFeet, 0, False, False)
preResult.append(newWall)
except Exception as e:
errorReport = e.message
msg = "Não foi possível criar essa parede\n" + errorReport
preResult.append(msg)
result.append(preResult)
preResult = []
t.Commit()
`
What did you expect to see?
Curves converted
What did you see instead?
My Python script returned the following message: Exception: The multiplicities of other interior knots must be at most degree - 2 Parameter name: knots
What packages or external references (if any) were used?
(Fill in here)
Stack Trace
(From the Dynamo crash window select 'Details' -> 'Copy' and paste here)
OS: Microsoft Windows NT 10.0.18363.0
CLR: 4.0.30319.42000
Dynamo: 2.3.0.5885
FYI @ZiyunShang @AndyDu1985
Hi @ricardyn , I just tried "ToRevitType()",
Here is my python script:
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
# Place your code below this line
curves=dataEnteringNode[0]
curvesAsRevitTypes=[]
for crv in curves:
curvesAsRevitTypes.append(crv.ToRevitType())
# Assign your output to the OUT variable.
OUT = curvesAsRevitTypes
Could you provide your script and model so that I could reproduce on my side?
Thx for your attention.
I'm sorry, but I can not shared any files because of the confidentiality of them.
In other wise, I can tell you that the source of the problem are NURBS with degree <= 2 generated by polycurve offset node.
In order to get around this problem I did two things:
-
before offset, simplify Rooms curves using a implementation adapted of Rammer-Douglas-Peucker algorithm.
-
rebuild curves. Cast them back to lines and arcs and them create walls.
I have a similar problem.. I am not even extracting complex shapes .. I just drew a simple rectangle ... Here is my script import sys import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import *
p1 = Point.ByCoordinates(0,0,0) p2 = Point.ByCoordinates(0,1000,0) p3 = Point.ByCoordinates(1000,1000,0) p4 = Point.ByCoordinates(1000,0,0) p12 = Point.ByCoordinates(0,0,1000) p22 = Point.ByCoordinates(0,1000,1000) p32 = Point.ByCoordinates(1000,1000,1000) #example for data entery from previuous dynamo /python steps point_list_dynamo = [[p1,p2,p3,p4],[p12,p22,p32]] cross1 = Polygon.ByPoints(point_list_dynamo[0]) cross2 = Polygon.ByPoints(point_list_dynamo[1]) cross_sections = [cross1,cross2] #WORK STARTS HERE
clr.AddReference('RevitNodes') import Revit from Revit.Elements import * clr.ImportExtensions(Revit.Elements) clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitAPI') clr.AddReference('RevitAPIUI') import Autodesk from Autodesk.Revit.DB import * from Autodesk.Revit.UI import * clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc) #convert dynamo points to revet points
lines = cross_sections[0].ToRevitType()
TransactionManager.Instance.TransactionTaskDone()