How to place line in drafting view using python script


#Preparing input from dynamo to revit
VV = UnwrapElement(IN[0])

#Do some action in a Transaction


TransactionManager.Instance.EnsureInTransaction(doc)

draftingview1 = DraftingView.ByName(vv)
view1 = Elements.Views.View.SetScale(draftingview1, 1)
pt1 = Autodesk.Point.ByCoordinates(0, 0)
pt2 = Autodesk.Point.ByCoordinates(5000, 0)
line1 = Autodesk.Line.ByStartPointEndPoint(pt1, pt2)
detailcurve1 = DetailCurve.ByCurve(view1, line1)

#detailcurve1 = doc.Create.NewDetailCurve(view1, line1)

TransactionManager.Instance.TransactionTaskDone()

OUT = detailcurve1

It is working with Code Block. But it is not working inside the python script

Hello,

whats your imput?

i see some syntexstuff vv VV, DraftingView is named differently:

use the template from Primier Dynamo Python.

KR

Andreas

@auriffbasha.capital it is not that simple to just “Node to Code” nodes and gets them to work in python,
this will get you started:

import clr

clr.AddReference('RevitServices')
import RevitServices

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc =  DocumentManager.Instance.CurrentDBDocument

vType = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements()

for v in vType:
	if v.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString() == "Detail":
		vId = v.Id

TransactionManager.Instance.EnsureInTransaction(doc)
	
draftV = ViewDrafting.Create(doc, vId)

p0 = XYZ(0,0,0)
p1 = XYZ(5000,0,0)
curve = Line.CreateBound(p0, p1)

dCurve = doc.Create.NewDetailCurve(draftV, curve)   

TransactionManager.Instance.TransactionTaskDone()

OUT = dCurve
3 Likes

Thank you,

But I want to place a line in particular Detail View.

@auriffbasha.capital something like this?
P.S.: when you want to mention someone, please use “@” character

import clr

clr.AddReference('RevitServices')
import RevitServices

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc =  DocumentManager.Instance.CurrentDBDocument

vType = FilteredElementCollector(doc).OfClass(ViewDrafting).ToElements()

for v in vType:
	if v.Name == IN[0]:
	#if v.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString() == "Detail":
		#vId = v.Id
		draftV = v

TransactionManager.Instance.EnsureInTransaction(doc)
	
#draftV = ViewDrafting.Create(doc, vId)

p0 = XYZ(0,0,0)
p1 = XYZ(5000,0,0)
curve = Line.CreateBound(p0, p1)

dCurve = doc.Create.NewDetailCurve(draftV, curve)   

TransactionManager.Instance.TransactionTaskDone()

OUT = dCurve
1 Like

@Elie.Trad, Its working, Thankyou so much

1 Like