Hi
I´m new using python for rhino.inside Revit. I was wondering if there was some web pages you recommend in order to improve my skills. Thanks in advice.
Also, i was trying to understand a script today but i can´t figure it out. I can´t understand where is defined CGL, and where does CG comes from. Thanks in advice.
import clr
clr.AddReference(‘System.Core’)
clr.AddReference(‘RhinoInside.Revit’)
clr.AddReference(‘RevitAPI’)
clr.AddReference(‘RevitAPIUI’)
from System import Enum
import rhinoscriptsyntax as rs
import Rhino
import RhinoInside
import Grasshopper
from Grasshopper.Kernel import GH_RuntimeMessageLevel as RML
from RhinoInside.Revit import Revit, Convert
from Autodesk.Revit import DB
clr.ImportExtensions(RhinoInside.Revit.Convert.Geometry)
active Revit verison
REVIT_VERSION = Revit.ActiveUIApplication.Application.VersionNumber
access the active document object
doc = Revit.ActiveDBDocument
def show_warning(msg):
ghenv.Component.AddRuntimeMessage(RML.Warning, msg)
def show_error(msg):
ghenv.Component.AddRuntimeMessage(RML.Error, msg)
def show_remark(msg):
ghenv.Component.AddRuntimeMessage(RML.Remark, msg)
create and start the transaction
t = DB.Transaction(doc, ‘AddGridLine’)
t.Start()
try:
# change Revit document here
CGL = CG.AddGridLine(U, DB.XYZ(P.X, P.Y, P.Z), False)
# commit the changes after all changes has been made
t.Commit()
except Exception as txn_err:
# if any errors happen while changing the document, an exception is thrown
# make sure to print the exception message for debugging
print(str(txn_err))
# and rollback the changes made before error
try:
t.RollBack()
except Exception as rb_err:
print(str(rb_err))
The pyrevit tutorials are a good place to start.
The CGL is a Curtain Grid Line, Analyze a Curtain Wall and you will see those outputs.
Thanks a lot!