Pick new host rebar


pick new host rebar?

Hello! Here is the anwer:

http://www.revitapidocs.com/2018.1/79da5994-50ed-171f-adf2-9a6550c898db.htm

Can you help me creat node?

It depends on how much help you need.

You need two inputs, let’s name them rebarElement and hostElement

Then between transaction start and commit write something like this:

rebarElement.SetHostId(doc, hostElement.Id)

1 Like


Can you help me write this node?

If you need help to review something wrong in your code, you will find here how to paste what you have done so far:

I tried to do the same thing as pvhuyg and it seems that my Dynamo script can’t access the attribute SetHostID
It also couldn’t get the ID of the desired host element with “hostElement.id”

Is there anything im missing out in the Code?

Edit/Update 1: i found out the element im trying to feed into the Python Script is a RebarInSystem class not the RebarClass. Unfortunately the RebarInSystem class does not provide a SetHostId Method. Still trying to figure out to make it work :confused:

# Phython-UnterstĂĽtzung aktivieren und DesignScript-Bibliothek laden
import clr
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import System

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)


# Die Eingaben fĂĽr diesen Block werden in Form einer Liste in den IN-Variablen gespeichert.
rebarElement = UnwrapElement(IN[0])
hostElement = UnwrapElement(IN[1])

# Code unterhalb dieser Linie platzieren

if IN[2]==True:
	rebarElement.SetHostID(doc,hostElement)
	
	OUT = hostElement
else:
	OUT = "not run"
	
TransactionManager.Instance.TransactionTaskDone()
# Weisen Sie Ihre Ausgabe der OUT-Variablen zu.

Try rebarElement.SetHostId(doc, hostElement) instead.

1 Like

Thank you @MartinSpence that solved my Problem

Excellent :ok_hand: