Hello!
There’s two topics I’d like to ask about.
The first is related to interpreting the attribute user text function outputs.
I want to use a UserString to retrieve data about an object.
CRhinoCommand::result CCommandTestPrintLayer::RunCommand(const CRhinoCommandContext& context) {
CRhinoGetObject go;
go.SetCommandPrompt(L"Select object");
go.GetObjects();
if (go.CommandResult() != CRhinoCommand::success) {
RhinoApp().Print(L"No objects selected");
return go.CommandResult();
}
if (go.ObjectCount() == 0) {
RhinoApp().Print(L"No objects selected");
return CRhinoCommand::nothing;
}
CRhinoObjRef ref = go.Object(0);
const CRhinoObject* obj = ref.Object();
ON_wString layerName;
if (!obj->Attributes().GetUserString(L"ObjectLayer", layerName)) {
RhinoApp().Print(L"User string inactive");
return CRhinoCommand::nothing;
}
RhinoApp().Print(L"%ls\n", layerName);
return CRhinoCommand::success;
}
The output of the above is:
%<ObjectLayer(“45b2a3dd-be5c-4bda-b5cc-a286bacf7d4e”)>%
Is there a way to get the layer name from this string? Rhino automatically interprets it when used in an annotation object. I know I could get the layer name in a different way, but I want to use the UserData more generally and handle the edge cases of these default functions.
I’m also having trouble with clipping planes and custom conduit bounding boxes.
The actual code gets a set of corners from an object pointer, but aside from that this is basically the rest of the conduit code:
class TestConduit : public CRhinoDisplayConduit {
ON_3dPointArray m_corners;
public:
TestConduit() : CRhinoDisplayConduit(CSupportChannels::SC_CALCBOUNDINGBOX | CSupportChannels::SC_PREDRAWOBJECTS) {
m_corners.Append(ON_3dPoint(0, 0, 0));
m_corners.Append(ON_3dPoint(1000, 0, 0));
m_corners.Append(ON_3dPoint(1000, 1000, 0));
m_corners.Append(ON_3dPoint(0, 1000, 0));
m_corners.Append(ON_3dPoint(0, 0, 0));
}
bool ExecConduit(CRhinoDisplayPipeline& dp, UINT nActiveChannel, bool& bTerminate) override {
if (nActiveChannel == CSupportChannels::SC_CALCBOUNDINGBOX) {
m_pChannelAttrs->m_BoundingBox = ON_BoundingBox::EmptyBoundingBox;
m_pChannelAttrs->m_BoundingBox.Union(m_corners.BoundingBox());
m_pChannelAttrs->m_BoundingBox.Union(m_points.BoundingBox());
}
else if (nActiveChannel == CSupportChannels::SC_PREDRAWOBJECTS) {
for (int i = 0; i < 4; i++)
dp.DrawLine(m_corners[i], m_corners[i + 1]);
}
return true;
}
};
Hopefully this image gives some clues as to what is happening.