Get Model -> Paper scale within conduit's ExecConduit


We are trying to draw some text with a conduit on a detailed view in a page layout. For this we want to draw the text always in the same height that it looks like a technical drawing. But when the detail view has a paper - model scaling other than 1:1 we cannot retrieve the right transformation.

What we have done so far to draw a 2mm height text on a detail view with 1:1 scaling:

  1. Get view transformation to orient the text always horizontal and in view direction

ON_Xform w2s_neu;
ON_3dVector y = vp.VP().CameraUp();
ON_3dVector z = vp.VP().CameraDirection(); z.Reverse();
ON_3dVector x = ON_CrossProduct(y, z);
w2s_neu.Rotation(ON_3dVector::XAxis, ON_3dVector::YAxis, ON_3dVector::ZAxis, x, y, z);

  1. Get text scale

ON_Xform scalePos;
scalePos.Scale(posTextHeight * corr, posTextHeight * corr, posTextHeight * corr);

  1. Get point translation

ON_Xform trans;

  1. Set model transformation of the viewport

dp.GetRhinoVP().SetModelXform(trans * scalePos * w2s_neu);

  1. Draw text

CRhinoText rt;
dp.DrawString(ON_Plane(ON_3dPoint(0.1, 0.1, 0), ON_3dVector::ZAxis), ON_Color(0, 0, 0), rt);

If i now change the scaling of the detail view the text size also changes accordingly which is not wanted!

My question: how can i retrieve the paper - model scaling of the detail view which i am currently draw on?

(Dale Fugier) #4

Hi Wolfgang,

Use CRhinoDetailViewObjec::GetModelLength.

For example

double detail_scale = 1.0;
detail->GetModelLength(1.0, detail_scale);

– Dale


Hi Dale,

yes that would be the right scale, but how do i get the CRhinoDetailViewObject of the current display pipeline?

(Dale Fugier) #6

Hi Wolfgang,

This should do it:

bool CTestConduit::ExecConduit(CRhinoDisplayPipeline& dp, UINT nChannel, bool&)
  if (nChannel == CSupportChannels::SC_DRAWOBJECT)
    CRhinoDetailViewObject* active_detail = 0;
    CRhinoView* view = dp.GetRhinoVP().ParentView();
    if (0 != view && view->IsKindOf(RUNTIME_CLASS(CRhinoPageView)))
      CRhinoPageView* page_view = static_cast<CRhinoPageView*>(view);
      if (0 != page_view)
        active_detail = page_view->FindActiveDetailObject();
    if (0 != active_detail)
      // TODO....
  return true;

– Dale


Hi Dale,

sorry, didn’t work for me. I do not get the CRhinoDetailViewObject for this pipeline, i just get NULL.

Have you tried it on your own?

(Dale Fugier) #8

Hi Wolfgang,

If you make a detail active, the code I posted will retrieve the active CRhinoDetailViewObject object.

– Dale