mcneel / rhino.inside-revit

This is the open-source repository for Rhino.Inside®.Revit
https://www.rhino3d.com/inside/revit/
MIT License
262 stars 67 forks source link

Topography by Mesh #166

Closed alfonsomonedero closed 4 years ago

alfonsomonedero commented 4 years ago

Describe the bug I am trying to create a Topography by Mesh node, it is fully working in Dynamo Python so it should be straight forward to convert into Rhino.Inside. Revit is throwing an exception:

A transaction or sub-transaction was opened but not closed. All changes to the active document made by External Command will be discarded.

import clr
clr.AddReference('System.Core')
clr.AddReference('RhinoInside.Revit')
clr.AddReference('RevitAPI') 
clr.AddReference('RevitAPIUI')

import rhinoscriptsyntax as rs
import Rhino
import RhinoInside
import Grasshopper
from RhinoInside.Revit import Revit
from Autodesk.Revit import DB

import System

doc = Revit.ActiveDBDocument
faces = []
for i in range(MeshFaces.BranchCount):
    branchList = MeshFaces.Branch(i)
    branchPath = MeshFaces.Path(i)
    faces.append(DB.PolymeshFacet(branchList[0],branchList[1],branchList[2]))
t = DB.Transaction(doc, "Create Topo from Mesh")

if run:
    t.Start()
    topo = DB.Architecture.TopographySurface.Create(doc, Points, faces)
    t.Commit()

Change the extension of the txt to gh and you will see the script. TopoFromMesh.txt

eirannejad commented 4 years ago

Hey @alfonsomonedero Take a look at this and make sure to handle your transactions inside the python code as sugegsted.

https://www.rhino3d.com/inside/revit/beta/guides/rir-ghpython#handling-transactions

kike-garbo commented 4 years ago

image