29 #define _unused(x) ((void)(x)) 33 #include "SUAPI-CppWrapper/model/ComponentInstance.hpp" 35 #include <SketchUpAPI/model/group.h> 37 #include "SUAPI-CppWrapper/String.hpp" 53 return new_instance.
ref();
65 DrawingElement(SUComponentInstanceToDrawingElement(instance), attached)
75 DrawingElement(other, SUComponentInstanceToDrawingElement(instance_ref))
81 SUComponentInstanceRef instance = SUComponentInstanceFromEntity(
m_entity);
82 SUResult res = SUComponentInstanceRelease(&instance);
83 assert(res == SU_ERROR_NONE); _unused(res);
93 SUComponentInstanceRef instance;
95 if (SUEntityGetType(
m_entity) == SURefType_Group) {
96 SUGroupRef group = SUGroupFromEntity(
m_entity);
97 instance = SUGroupToComponentInstance(group);
100 instance = SUComponentInstanceFromEntity(
m_entity);
102 SUResult res = SUComponentInstanceRelease(&instance);
103 assert(res == SU_ERROR_NONE); _unused(res);
114 if (type == SURefType_Group) {
115 SUGroupRef group_ref = SUGroupFromEntity(
m_entity);
116 return SUGroupToComponentInstance(group_ref);
118 return SUComponentInstanceFromEntity(
m_entity);
122 ComponentInstance::operator SUComponentInstanceRef()
const {
129 throw std::logic_error(
"CW::ComponentInstance::transformation(): ComponentInstance is null");
131 SUTransformation transform;
132 SUResult res = SUComponentInstanceGetTransform(this->
ref(), &transform);
133 assert(res == SU_ERROR_NONE); _unused(res);
140 throw std::logic_error(
"CW::ComponentInstance::transformation(): ComponentInstance is null");
142 SUTransformation su_transform = transform.ref();
143 SUResult res = SUComponentInstanceSetTransform(this->
ref(), &su_transform);
144 assert(res == SU_ERROR_NONE); _unused(res);
150 throw std::logic_error(
"CW::ComponentInstance::definition(): ComponentInstance is null");
152 SUComponentDefinitionRef component = SU_INVALID;
153 SUResult res = SUComponentInstanceGetDefinition(this->
ref(), &component);
154 assert(res == SU_ERROR_NONE); _unused(res);
161 throw std::logic_error(
"CW::ComponentInstance::name(): ComponentInstance is null");
164 SUStringRef *
const string_ref = string;
165 SUResult res = SUComponentInstanceGetName(this->
ref(), string_ref);
166 assert(res == SU_ERROR_NONE); _unused(res);
173 throw std::logic_error(
"CW::ComponentInstance::name(): ComponentInstance is null");
175 std::string name_string =
string.std_string();
176 SUResult res = SUComponentInstanceSetName(this->
ref(), name_string.c_str());
177 assert(res == SU_ERROR_NONE); _unused(res);
bool m_attached
Indicates whether the Entity has been attached to a model.
ComponentInstance create_instance() const
bool attached() const
Returns true if the entity is attached to another object.
SUComponentInstanceRef copy_reference(const ComponentInstance &other)
Transformation transformation() const
enum SURefType entity_type() const
Returns the type of the entity. See enum SURefType.
DrawingElement & operator=(const DrawingElement &other)
SUEntityRef m_entity
The C SUEntityRef that this class wraps.
ComponentDefinition definition() const
ComponentInstance & operator=(const ComponentInstance &other)
SUComponentInstanceRef ref() const