Author Topic: AcedJig and Complex entities.  (Read 4054 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7026
  • AKA Daniel
AcedJig and Complex entities.
« on: March 27, 2009, 01:08:54 AM »
It says in the ARX docs not to use Aced Jig with complex entities such as polylines

Quote
AcEdJig is generally used on entities that do not reside in the database. It operates on a single entity. Do not use AcEdJig to operate on complex entities such as polylines.

How about a LwPolyine?

pkohut

  • Guest
Re: AcedJig and Complex entities.
« Reply #1 on: March 27, 2009, 01:44:20 AM »
AcDbPolyline is fine.

Complex entites are

AcDbBlockReference
AcDb2dPolyline
AcDb3dPolyline
AcDbPolygonMesh
AcDbPolyFaceMesh
AcDbMInsertBlock

Paul

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7026
  • AKA Daniel
Re: AcedJig and Complex entities.
« Reply #2 on: March 27, 2009, 02:11:21 AM »
Awesome! Thanks Paul.

Here is a sample if anyone needs one (AcDbPolyLine)

.h

Code: [Select]
#pragma once

class RectJig : public AcEdJig
{
  // fields
private:
  Adesk::Boolean m_append;
  AcGePoint3d m_cur;
  AcGePoint3d m_last;
  const CString m_msg;
  AcDbPolyline *m_line;
  AcDbObjectId m_id;

public:
  // ctor && dtor
  RectJig(double width, double height, const CString &msg, Adesk::Boolean append = Adesk::kTrue);
  virtual ~RectJig(void);

  // methods
  void doIt();
  Adesk::Boolean cursorHasMoved(void);
  virtual AcEdJig::DragStatus sampler(void);
  virtual Adesk::Boolean update(void);
  virtual AcDbEntity* entity(void) const;
  AcGePoint2d getPoint2d(void) const;
  AcGePoint3d getPoint3d(void) const;
  AcDbObjectId getObjectId(void)const;
  __declspec(property(get = getPoint2d))AcGePoint2d Point2d;
  __declspec(property(get = getPoint3d))AcGePoint3d Point3d;
  __declspec(property(get = getObjectId))AcDbObjectId ObjectId;
};

.cpp
Code: [Select]
#include "StdAfx.h"
#include "JigTest.h"


RectJig::RectJig(double width, double height, const CString &msg, Adesk::Boolean append /*= Adesk::kTrue*/)
:m_append(append), m_line(new AcDbPolyline(4)), m_cur(AcGePoint3d::kOrigin),
m_last(AcGePoint3d::kOrigin) , m_msg(msg) , m_id(AcDbObjectId::kNull)
{
  AcGePoint2d pt0(m_cur.x, m_cur.y);
  AcGePoint2d pt1(pt0.x + width,pt0.y);
  AcGePoint2d pt2(pt0.x + width, pt0.y + height);
  AcGePoint2d pt3(pt0.x, pt0.y + height);

  this->m_line->addVertexAt(0,pt0);
  this->m_line->addVertexAt(1,pt1);
  this->m_line->addVertexAt(2,pt2);
  this->m_line->addVertexAt(3,pt3);
  this->m_line->setClosed(Adesk::kTrue);
}

RectJig::~RectJig(void)
{
  if(!m_append)
  {
    delete m_line;
  }
}

inline Adesk::Boolean RectJig::cursorHasMoved( void )
{
  return this->m_cur != this->m_last;
}

AcEdJig::DragStatus RectJig::sampler()
{
  setUserInputControls(UserInputControls(kAccept3dCoordinates));

  if(acquirePoint(m_cur) != AcEdJig::kNormal)
  {
    return AcEdJig::kCancel;
  }

  if(this->cursorHasMoved())
  {
    return AcEdJig::kNormal;
  }
  return AcEdJig::kNoChange;
}

Adesk::Boolean RectJig::update(void)
{
  if(this->m_line->transformBy(AcGeMatrix3d::translation(AcGeVector3d(m_cur - m_last))) != Acad::eOk)
  {
    return Adesk::kFalse;
  }
  m_last = m_cur;
  return Adesk::kTrue;
}

AcDbEntity* RectJig::entity(void) const
{
  return this->m_line;
}

void RectJig::doIt(void)
{
  setDispPrompt(m_msg);

  if(drag() != AcEdJig::kNormal)
  {
    m_append = Adesk::kFalse;
  }

  if(m_append)
  {
    m_id = append();
    m_line->close();
  }
}

AcGePoint2d RectJig::getPoint2d(void) const
{
  return AcGePoint2d(m_last.x, m_last.y);
}

AcGePoint3d RectJig::getPoint3d(void) const
{
  return m_last;
}

AcDbObjectId RectJig::getObjectId( void ) const
{
  return m_id;
}

and command

Code: [Select]
static void CabDraw_RectJig(void)
  {
    RectJig jig(100,100, _T("Pick Start Point: "));
    jig.doIt();
    acutPrintf(_T("\n%g,%g"),jig.Point2d.x, jig.Point2d.y);
  }

Edit Added objectid property
« Last Edit: March 27, 2009, 03:09:28 AM by Daniel »

pkohut

  • Guest
Re: AcedJig and Complex entities.
« Reply #3 on: March 27, 2009, 02:27:21 AM »
 :-D The function "doIt" sure makes a lot of cameos in your code  :-D

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7026
  • AKA Daniel
Re: AcedJig and Complex entities.
« Reply #4 on: March 27, 2009, 02:38:40 AM »

Iím just a noob   :mrgreen:

pkohut

  • Guest
Re: AcedJig and Complex entities.
« Reply #5 on: March 27, 2009, 02:57:28 AM »
Ah FooBar  :lmao:



Iím just a noob   :mrgreen:


Spike Wilbury

  • Guest
Re: AcedJig and Complex entities.
« Reply #6 on: March 27, 2009, 11:58:50 AM »
Daniel,

Any reason about not using the samples for example for the command RECT ?

Anyway, I am not great fan of AcedJig - have used this class for a few commands, but for example, try to write one that emulates the command PLINE - in my case, I end up doing a separate function.

There is one MPOLY done by Kean W. but does not work as PLINE.... BTW


Just want it to comment about it.... :)

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7026
  • AKA Daniel
Re: AcedJig and Complex entities.
« Reply #7 on: March 27, 2009, 09:14:22 PM »
Hi Luis,
I didnít remember that was in there.. I kind of used the ellipsejig sample as a guide