[Edit Moderation]
I don’t understood how to change ToXyz converts the Dynamo point to Revit type.
please give me a suggestion. read below link.
Python 0.6.3 to 0.7.x Migration · DynamoDS/Dynamo Wiki · GitHub
[Edit Moderation]
I don’t understood how to change ToXyz converts the Dynamo point to Revit type.
please give me a suggestion. read below link.
Python 0.6.3 to 0.7.x Migration · DynamoDS/Dynamo Wiki · GitHub
i have solve this problem.
but new problem is the crop region is not set.
please help me solve this.
import clr
clr.AddReference('RevitAPI')
clr.AddReference("RevitServices")
clr.AddReference("RevitNodes")
import RevitServices
import Revit
import Autodesk
from Autodesk.Revit.DB import *
import math
clr.ImportExtensions(Revit.GeometryConversion)
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
toggle = IN[0]
points = UnwrapElement(IN[1])
modelPoints = UnwrapElement(IN[2])
cropCurves = UnwrapElement(IN[3])
viewType = UnwrapElement(IN[4])
lst = []
if toggle == True:
TransactionManager.Instance.EnsureInTransaction(doc)
for ind, point in enumerate(points):
modelMP = modelPoints[ind].ToXyz()
modelMPX = modelMP.X
modelMPY = modelMP.Y
cropLines = cropCurves[ind]
l1 = cropLines[0].ToRevitType()
l2 = cropLines[1].ToRevitType()
l3 = cropLines[2].ToRevitType()
l4 = cropLines[3].ToRevitType()
elevationPT = point.ToXyz()
elptRotate = XYZ(elevationPT.X, elevationPT.Y, elevationPT.Z+100)
ln = Line.CreateBound(elevationPT, elptRotate)
elevationPTY = elevationPT.Y
elevationPTX = elevationPT.X
combY = elevationPTY-modelMPY
combX = elevationPTX-modelMPX
ang = math.atan2(combY, combX)
eleMarker = ElevationMarker.CreateElevationMarker(doc, viewType.Id, elevationPT, 100)
ele = eleMarker.CreateElevation(doc, doc.ActiveView.Id, 0)
ElementTransformUtils.RotateElement(doc, eleMarker.Id, ln, ang)
crManager = ele.GetCropRegionShapeManager()
newCurveLoop = []
newCurveLoop.Add(l1)
newCurveLoop.Add(l2)
newCurveLoop.Add(l3)
newCurveLoop.Add(l4)
cLoop =CurveLoop.Create(newCurveLoop)
try:
crManager.SetCropRegionShape(cLoop)
lst.append("Elevation Created")
except:
pass
lst.append("Missed Eleevation")
TransactionManager.Instance.TransactionTaskDone()
OUT = lst
Hello @robert12546358
ViewCropRegionShapeManager.SetCropRegionShape(CurveLoop)
is an old method, try to replace by
ViewCropRegionShapeManager.SetCropShape(CurveLoop)
https://www.revitapidocs.com/2016/190e84cf-b821-a203-d6a8-34e4c0b13e76.htm
Any Dynamo expert online? I need help !
Start a new topic describing briefly your issue.
I made it but nobody answer it ! ! !
I answered in your topic.
Avoid jumping in other posts. If the topic was not answered you can send reminder on the same topic.
Thanks for your reply c.poupin
Can you give me a script add new method of View crop. because i am not a professional developer.
Many Thanks in Advanced
it is possible output as view.
Hello
an example with a wall
import clr
import sys
import math
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
def getFaceloop(wall):
lstref = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior)
for ref in lstref:
face = wall.GetGeometryObjectFromReference(ref)
edgLoopArr = face.EdgeLoops
for lstEdg in edgLoopArr:
lstCurvDS = [x.AsCurve().ToProtoType() for x in lstEdg]
polycurvDS = DS.PolyCurve.ByJoinedCurves(lstCurvDS)
lstCurv = List[Curve]([x.ToRevitType() for x in polycurvDS.Curves()])
curvLoop = CurveLoop.Create(lstCurv)
return curvLoop
wall = UnwrapElement(IN[0])
vft = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements().Find(lambda i : i.ViewFamily == ViewFamily.Elevation)
viewTypeId = vft.Id
TransactionManager.Instance.EnsureInTransaction(doc)
#get propreties
curvloopWall = getFaceloop(wall)
locCurv = wall.Location.Curve
vectA = locCurv.Direction.Normalize()
offSetCurve = locCurv.CreateOffset(2, vectA.CrossProduct(XYZ(-1,0,0)))
pt = offSetCurve.Evaluate(0.5, True)
ln = Line.CreateBound(pt, pt + XYZ(0,0,10))
ang = vectA.AngleTo(XYZ(1,0,0)) * XYZ(1,0,0).CrossProduct(vectA).Normalize().Z
#create marker
eleMarker = ElevationMarker.CreateElevationMarker(doc, viewTypeId, pt, 100)
indXElev = 0 if ang > 0 else 2
ele = eleMarker.CreateElevation(doc, doc.ActiveView.Id , indXElev)
rot = eleMarker.Location.Rotate(ln, ang + math.pi / 2)
#set cropShape
crManager = ele.GetCropRegionShapeManager()
crManager.SetCropShape(curvloopWall)
TransactionManager.Instance.TransactionTaskDone()
OUT = eleMarker
Thanks for your script, it’s working very well.
I have one more condition add in script.
In wall which face get a paint material that side create a elevation view of the wall. Is it possible?
Yes it’s possible by several steps
1/ get all faces of the wall (with HostObjectUtils.GetSideFaces() method)
2/ get and check material Name for each face
materialFace = doc.GetElement(face.MaterialElementId)
if "myPaint" in materialFace.Name:
#...
#ToDo
3/ if True, return the curvloop of this face, and his FaceNormal vector to position the mark on the correct side of the wall
4/ create the marker
the direction of the wall must also be taken into account to calculate the correct angle of rotation of the mark
Thanks c.poupin for your reply,
for single wall its work properly, but whenever I try to run with multiple wall it show listed warning( see attached snip).
Hello @robert12546358
@jacob.small has already responded to your request in this topic have you tried to follow his advice?
Note:
if you are a beginner avoid copying and pasting pieces of code this is not the best way to progress
Thanks @c.poupin
I want to learn Dynamo Python, from google I get Python for website an other thing only.
Please share if you have any source for Python language learning for Dynamo Python.
Much appreciate