Author Topic: Leader && jig.  (Read 1444 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Leader && jig.
« on: May 08, 2010, 09:27:30 AM »
For some reason, when I set my leader to setToSplineLeader, it no longer shows up in my jig? what am I doing wrong?

Thanks

Code: [Select]
#pragma once
#include "dbjig.h"

class LeaderJig : public AcEdJig
{
private:
  AcGePoint3d m_curpnt;
  AcGePoint3d m_lastpnt;
  AcDbObjectId m_id;
  AcDbLeader *m_leader;

public:
  LeaderJig();
  virtual ~LeaderJig(void);
  virtual AcEdJig::DragStatus sampler( void );
  virtual Adesk::Boolean update(void);
  virtual AcDbEntity* entity(void) const;
  Acad::PromptStatus doit (void);
  int GetStartPoint(AcGePoint3d & startPt);


  const AcDbObjectId& getObjectId() const { return m_id; }
  __declspec(property(get = getObjectId))AcDbObjectId ObjectId;

};

Code: [Select]
#include "StdAfx.h"
#include "LeaderJig.h"

LeaderJig::LeaderJig()
: AcEdJig(), m_curpnt(0.0,0.0,0.0), m_lastpnt(0.0,0.0,0.0), m_id(0),m_leader(0)
{
  m_leader = new AcDbLeader();
  m_leader->setDatabaseDefaults();
  m_leader->setToSplineLeader(); //<<<------------------------------
}

LeaderJig::~LeaderJig(void)
{
  if(m_id == AcDbObjectId::kNull)
    delete m_leader;
}

AcEdJig::DragStatus LeaderJig::sampler( void )
{
  setUserInputControls(
    UserInputControls(kAccept3dCoordinates|kNullResponseAccepted));
  return  acquirePoint(m_curpnt,m_lastpnt);
}

Adesk::Boolean LeaderJig::update( void )
{
  return kTrue;
}

AcDbEntity* LeaderJig::entity( void ) const
{
  return m_leader;
}

int LeaderJig::GetStartPoint( AcGePoint3d &startPt )
{
  int rVal = acedGetPoint(NULL, _T("\nSpecify start point: "), asDblArray(startPt));
  acdbUcs2Wcs(asDblArray(startPt),asDblArray(startPt),false);
  return rVal;
}

Acad::PromptStatus LeaderJig::doit( void )
{
  DragStatus stat = kNormal;

  if(GetStartPoint(m_curpnt) != RTNORM)
    return Acad::eError;

  while(stat == kNormal)
  {
    acutPrintf(_T("\nSpecify next point: "));
    m_lastpnt = m_curpnt;
    m_leader->appendVertex(m_curpnt);
    stat = drag();
  }

  if( (m_id = append()) == AcDbObjectId::kNull)
    return Acad::eError;

  return Acad::eNormal;
}