Skip to content

Commit

Permalink
Fix #4997 - Add Workspace casting methods in python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
jmarrec authored and wenyikuang committed Oct 17, 2023
1 parent 9e2cdce commit d96016b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/model/ModelCore.i
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,46 @@
// Model = openstudiomodelcore.Model
// %}

%pythoncode %{
def _workspace_to_Model(self) -> Model:
"""Cast the Workspace to a Model.
Throws if not an actual Model
:return: A Model.
"""
return toModel(self)
openstudioutilitiesidf.Workspace.to_Model = _workspace_to_Model

def _workspace_to_OptionalModel(self) -> OptionalModel:
"""Try to cast the Workspace to a Model.
:return: An OptionalModel.
"""
return toOptionalModel(self)
openstudioutilitiesidf.Workspace.to_OptionalModel = _workspace_to_OptionalModel



def _workspace_to_Component(self) -> Component:
"""Cast the Workspace to a Component.
Throws if not an actual Component
:return: A Component.
"""
return toComponent(self)
openstudioutilitiesidf.Workspace.to_Component = _workspace_to_Component

def _workspace_to_OptionalComponent(self) -> OptionalComponent:
"""Try to cast the Workspace to a Component.
:return: An OptionalComponent.
"""
return toOptionalComponent(self)
openstudioutilitiesidf.Workspace.to_OptionalComponent = _workspace_to_OptionalComponent
%}

#else

#endif
Expand Down

0 comments on commit d96016b

Please sign in to comment.