Instantiate revit families from Rhino Inside

python
unhandled
rhinoinsiderevit
(Sounok9413) #1

Is there a way to instantiate revit families in the revit doc from Rhino Inside? I could not find a way to access the current revit doc from Rhino inside. Would be really helpful if there was a way to do that.

(Kike Garcia) #2

Hi,

I see you used the tag ‘python’.
You need to do it using Python or is it fine if you can use Grasshopper to do it?

1 Like
(Sounok9413) #3

If you have that component in grasshopper I can access that in python by importing the gh library if need be.

(Sounok9413) #4

Hi,

Any updates on this?

(Kike Garcia) #5

Still not.

But It’s in the list at the very top.

2 Likes
(Sounok9413) #6

Hello,

I solved the issue. Basically made a node in grasshopper following the rhino inside documentation in github. But that led to a more interesting problem. Is it possible to add a node in grasshopper that opens and closes transaction for other changes (mirroring, deleting, moving etc.) to be made in revit doc. Or how to run it from python in grasshopper. I guess as I am running it from grasshopper, the standard way to open transaction: “TransactionManager.Instance.EnsureInTransaction(Revit.ActiveDBDocument)” returns an error. Any hint on this would be really helpful.

Thanks.

(Kike Garcia) #7

I’ve updated the repository with a component to add Family Instances to the Revit document.

Also added support to Revit 2020 for any of you that have already updated your Revit.

About the standard way of starting a transaction in Revit I recommend you to use the code bellow.

  using (var trans = new Transaction(Revit.ActiveDBDocument))
  {
    try
    {
      if (trans.Start("TransactionName") == TransactionStatus.Started)
      {
        // Your Revit document changes here...

        var status = trans.Commit();

        if (status == TransactionStatus.Committed)
        {
          // Your changes are made effective in the Revit document here.
        }
      }
    }
    catch (Exception)
    {
      if (trans.HasStarted())
        trans.RollBack();
    }
  }
2 Likes
(Sounok9413) #8

Thanks for the updates. Using the above transaction method in grasshopper I am getting the error:

Runtime error (InvalidOperationException): Starting a transaction from an external application running outside of API context is not allowed.