LDCad Detecting current editing plane using API?


Detecting current editing plane using API?
#1
Hi Roland,

is there an API call which returns the current editing plane? Something which perhaps returns a value of 1, 2 or 3?

By way of an example, when ctrl+R is pressed to open the Manual Rotation dialog, it knows the current editing plane to apply the rotation to. I'm wanting to modify the part alignment scripts to work based on the current rotation plane rather than making the user identify the X, Y or Z plane to be rotated around.

If an API call isn't available, can you guide me in the direction of a possible approach to try?

Thanks and regards,

David
Reply
RE: Detecting current editing plane using API?
#2
(2021-12-28, 2:44)David Manley Wrote: is there an API call which returns the current editing plane? Something which perhaps returns a value of 1, 2 or 3?

Not at the moment, but I will add it to the ldc.view object (along with some other things found in the compass).

You could calculate it yourself by using the current camera orientation if you really need it right now.
Reply
RE: Detecting current editing plane using API?
#3
(2021-12-29, 20:16)Roland Melkert Wrote: You could calculate it yourself by using the current camera orientation if you really need it right now.

Thank you.

From some preliminary script fiddling, presumably just based just on the Tilt and Yaw values, with the toggle point being at the +/- 45 degree angle and +/-135 degree angle. The Roll doesn't appear to influence the current editing plane. Is this interpretation along the correct lines?

David
Reply
RE: Detecting current editing plane using API?
#4
(2021-12-30, 8:17)David Manley Wrote: From some preliminary script fiddling, presumably just based just on the Tilt and Yaw values, with the toggle point being at the +/- 45 degree angle and +/-135 degree angle. The Roll doesn't appear to influence the current editing plane. Is this interpretation along the correct lines?

Seems ok, in case you want the exact same value here's the relevant LDCad source:
Code:
void TEditWindowSession::applyAutoEditPlane() {

  ldcAssert(perspective);

  const double minAngle=deg2Rad(40);
  const double nearZero=deg2Rad(1);

  TGLMatrixd matrix(getRotCtrl()->getRotationMatrix());
  matrix.mulOriWithGL(editSes->getGrid()->getOri());

  TGLVector3d dir(1.0, 0.0, 0.0), frusZ(0.0, 0.0, 1.0);
  dir.transform(matrix);
  double angleX=dir.unitAngleWith(frusZ);if (angleX>0.5*M_PI) angleX=M_PI-angleX; if (angleX<nearZero) angleX=minAngle;

  dir.init(0.0, 1.0, 0.0);
  dir.transform(matrix);
  double angleY=dir.unitAngleWith(frusZ);if (angleY>0.5*M_PI) angleY=M_PI-angleY; if (angleY<nearZero) angleY=minAngle;

  dir.init(0.0, 0.0, 1.0);
  dir.transform(matrix);
  double angleZ=dir.unitAngleWith(frusZ);if (angleZ>0.5*M_PI) angleZ=M_PI-angleZ; if (angleZ<nearZero) angleZ=minAngle;

  //Beste vlak kiezen dmv kleinste hoek tov z
  if (angleX<minAngle || angleY<minAngle || angleZ<minAngle)
  {
    if (angleX<angleZ)
    {
      if (angleX<angleY)
        setEditPlane(EP_YZ); //x
      else
        setEditPlane(EP_XZ); //y
    }
    else if (angleZ<angleY)
      setEditPlane(EP_XY); //z
    else
      setEditPlane(EP_XZ); //x
  }
  else
  {
    //90 deg (rounded) ori, gebruik de globale methode
    // dit kan niet altijd daar je een dode zone wilt (minAngle)
    matrix.orthoRoundRotation();
    setEditPlane(EPS2EP(roundedOrthoOri2EPS(matrix)));
  }
};

It basically does the same but it applies a 'dead-zone' so it won't jump around too match.
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 5 Guest(s)