I want to create this diagonal wall with dynamo, so I tried to extract edge from the wall, using SelectModelElement, which i can change the Z point of the edge, but I couldn’t find the node for extracting edge.
I even downloaded GeniusLoci package, but it doesn’t work, keep saying edges are null.
The code of the Wall Edges References node was written using the Python 2.7 engine.
So the DynamoIronPython2.7 package version 2.5 must also be installed for the custom node to run, as explained in the package description.
hello
I used this python code to create diagonal wall, and created successfully.
However, what I originally wanted to do was to extend and reduce the size of the wall freely.
It also works well, but the problem is, if I extend and reduce it, the wall that I just extended also exist on the revit, which originally does not have to exist. I don’t want to delete the useless wall, that I created before, one by one.
Is there a solution for this as well?
Also, I wanted to use this python code to create tilted ceiling. So I edited the code like this, but doesn’t work. How can I solve this problem? Could you please help?
Thank you.
Here is the code:
import clr
import System
from System.Collections.Generic import *
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry 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
Hi, if you want to modify the profile of your wall,
Check that the sketch is modifiable
You have a method in the Wall class
you will need
its skecthId (wall property)
Recover your skecth
Use the SketchEditScope Class
From what I understand, nothing is set in stone, I’m still babbling
It doesn’t seem that simple, I’ll try to dig deeper next weekend
Try it on your side in the meantime
Try not to digress in your post, people looking for it need to be able to find their way around it.
Sincerely
christian.stan
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)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = uiapp.ActiveUIDocument
wall_initial=UnwrapElement(IN[0])
prof_new_wall=IN[1]
cond_bool=wall_initial.CanHaveProfileSketch()
sketch_wall=doc.GetElement(wall_initial.SketchId)
if sketch_wall==None:
TransactionManager.Instance.EnsureInTransaction(doc)
sketch_wall=wall_initial.CreateProfileSketch()
doc.Regenerate()
TransactionManager.Instance.TransactionTaskDone()
out=[i.ToProtoType() for i in sketch_wall.Profile]
else:
out=[i.ToProtoType() for i in sketch_wall.Profile]
a=[i.Reference.ElementId for i in sketch_wall.Profile[0]]
sec=SketchEditScope(doc,'Delete and change the lines')
#open editscope
sec.Start(sketch_wall.Id)
TransactionManager.Instance.EnsureInTransaction(doc)
#Delete the Lines
for i in a:
doc.Delete(i)
#Send the new Lines
for i in prof_new_wall:
doc.Create.NewModelCurve(i.ToRevitType(),sketch_wall.SketchPlane)
TransactionManager.Instance.TransactionTaskDone()
sec.Commit()
OUT = cond_bool,out,a,sketch_wall
I’ve encountered the same issue you mentioned regarding the use of the Commit method in SketchEditScope when attempting to edit the sketch profile of a wall. Unfortunately, it seems that not many people have worked with this procedure before.
Were you ultimately able to use it successfully in Dynamo?
python code (IronPython3 or PythonNet3) No solution with CPython3 (especially with Revit 2024)
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
#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
class CreateFailureAdvancedHandler(IFailuresPreprocessor):
__namespace__ = "CreateFailureAdvancedHandler_jdtR0sA"
def PreprocessFailures(self, failuresAccessor):
failMessages = failuresAccessor.GetFailureMessages()
if failMessages.Count == 0:
return FailureProcessingResult.Continue
transName = failuresAccessor.GetTransactionName()
#
if failuresAccessor.GetSeverity() == FailureSeverity.Warning:
for currentMessage in failMessages:
failuresAccessor.DeleteWarning(currentMessage)
return FailureProcessingResult.Continue
#
elif failuresAccessor.GetSeverity() == FailureSeverity.Error:
for currentMessage in failMessages:
failuresAccessor.ResolveFailure(currentMessage)
return FailureProcessingResult.ProceedWithCommit
#
else:
pass
return FailureProcessingResult.Continue
wall = UnwrapElement(IN[0])
offset_value = 5
# offset point
TransactionManager.Instance.ForceCloseTransaction()
sketch = doc.GetElement(wall.SketchId)
curveArray = sketch.Profile[0] # assuming there is only 1 loop
# get top line
sort_curves = sorted(curveArray, key = lambda x : x.Evaluate(0.5, True).Z)
top_line = sort_curves[-1]
rest_curves = sort_curves[:2]
# get points on top line
pt1_old = top_line.GetEndPoint(0)
pt2 = top_line.GetEndPoint(1)
#
# find adjacent vertical line
vertical_line = next((c for c in rest_curves if c.Project(pt1_old).Distance < 0.01), None)
# bottom point on vertical line
pt3 = next((vertical_line.GetEndPoint(i) for i in range(2) if vertical_line.GetEndPoint(i).DistanceTo(pt1_old) > 0.1), None)
#
new_pt = pt1_old - XYZ(0,0,offset_value)
#
new_top_line = DB.Line.CreateBound(new_pt, pt2)
new_vertical_line = DB.Line.CreateBound(pt3, new_pt)
#
sketchEditScope = SketchEditScope(doc, "Update Wall")
sketchEditScope.Start(sketch.Id)
t = Transaction(doc, "Update Wall")
t.Start()
# Remove elements referenced by the found lines.
doc.Delete(top_line.Reference.ElementId)
doc.Delete(vertical_line.Reference.ElementId)
# Model curves creation automatically puts the curve into the sketch, if sketch edit scope is running.
doc.Create.NewModelCurve(new_top_line, sketch.SketchPlane)
doc.Create.NewModelCurve(new_vertical_line, sketch.SketchPlane)
t.Commit()
sketchEditScope.Commit( CreateFailureAdvancedHandler() )
t.Dispose()
#
OUT = wall