Hi @izzylys,
i ve watched your tutorial on how to create a revit beam via python. thanks!
could you kindly extend your example and show how to create a Revit Wall and Revit Window object via SpecklePy?
Could you provide a reference document of all attributes and types that exist in speckle and their
parameters? e.g. Revit Beam, Revit Steel Beam, ArchiCAD Wall etc…
Since you define the Revit Wall type here, are those types also understood by ArchiCAD?
Im receiving the following error when executing the Script multiple times. Perhaps you know how to solve it too
ValueError: The speckle_type: Objects.BuiltElements.Level is already registered for type: Level. Please choose a different type name.
we managed to go around question #4 with the following functions… but maybe not ideal.
cheers, matthias
def get_fully_qualified_name(cls):
return f"{cls.__module__}.{cls.__qualname__}"
keys_to_remove = []
for key, value in _RegisteringBase._type_registry.items():
print(key, value)
if get_fully_qualified_name(value).startswith("kumiki"):
keys_to_remove.append(key)
for key in keys_to_remove:
stype = _RegisteringBase._type_registry.get(key)
if stype:
del _RegisteringBase._type_registry[key]
Sorry about late reply. Let’s go over your questions.
Unfortunately, I can’t provide you a document that shows all the classes Speckle has, but even better, I can provide you the source code. You can find all the types and attributes here.
For creating custom objects with Specklepy, using these references, I’ll attach some examples below.
Here how you can create a RevitBeam:
from specklepy.objects import Base
from specklepy.objects.geometry import Line, Point
from specklepy.api.wrapper import StreamWrapper
from specklepy.api import operations
from typing import List, Optional
class Level(Base, speckle_type="Objects.BuiltElements.Level"):
"""
A custom Level class
"""
name: str = None
elevation: float = None
def __repr__(self) -> str:
return f"Level(id: {self.id}, name: {self.name}, elevation: {self.elevation})"
class RevitBeam(
Base, speckle_type="Objects.BuiltElements.Revit.RevitBeam", detachable={"level"}
):
"""
A custom RevitBeam class
"""
family: str = None
type: str = None
baseLine: Line = None
level: Level = None
units: str = None
displayValue: list = None # List[Mesh]
parameters: Base = None
elementId: str = None
def __repr__(self) -> str:
return f"RevitBeam(id: {self.id}, family: {self.family}, type: {self.type}, level: {self.level}, baseLine: {self.baseLine})"
# Create a level
level = Level(name="Level 0", elevation=0)
# Create a beam
beam = RevitBeam(
family="Structural Framing",
type="UB305x165x40",
level=level,
baseLine=Line(start=Point(x=0, y=0, z=0), end=Point(x=4, y=10, z=0)),
units="m",
)
# Create commit object
commit_obj = Base()
commit_obj["@revit beam from python"] = beam
# Send to Speckle
wrap = StreamWrapper(
"<YOUR_URL>"
)
client = wrap.get_client()
transport = wrap.get_transport()
obj_id = operations.send(commit_obj, [transport])
client.commit.create(wrap.stream_id, obj_id)
print(f"Successfully sent beam with ID: {obj_id}")
You’ll only see a base line in the viewer, but if you receive in Revit, this will create a Revit Beam for you.