Author Topic: My first custom object  (Read 6169 times)

0 Members and 1 Guest are viewing this topic.

Spike Wilbury

  • Guest
Re: My first custom object
« Reply #15 on: May 26, 2009, 10:24:31 AM »
Interesting! Is there a way I can protect my entity from such malicious attacks?

I noticed in one of my own, and I think we can monitor the command PEDIT and veto that command (have not done it my self in ARX) or make our own object using the primitives available or simple use an embedded AcDbPolyline.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6941
  • AKA Daniel
Re: My first custom object
« Reply #16 on: July 11, 2009, 08:41:55 PM »
Oops sorry for the late reply.
I have had a few requests to make add-ons for Bricscad... if that answers your qestion...  :-)

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6941
  • AKA Daniel
Re: My first custom object
« Reply #17 on: July 11, 2009, 08:44:18 PM »
Hey LE, how do I prevent the Trim command from cutting into my opbject?   :-)

Spike Wilbury

  • Guest
Re: My first custom object
« Reply #18 on: July 11, 2009, 11:30:35 PM »
Hey LE, how do I prevent the Trim command from cutting into my opbject?   :-)

opbject  What's this?    (he he.....)

You are deriving your object from AcDbPolyline... then just override these two methods:

virtual Acad::ErrorStatus getSplitCurves(const AcGeDoubleArray & params, AcDbVoidPtrArray & curveSegments) const;
virtual Acad::ErrorStatus getSplitCurves(const AcGePoint3dArray & points, AcDbVoidPtrArray & curveSegments) const;

and on the definition just place:

return Acad::eOk;


See if works.


It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6941
  • AKA Daniel
Re: My first custom object
« Reply #19 on: July 11, 2009, 11:38:23 PM »
Great, Thank you!

I will give it a shot :-)

Spike Wilbury

  • Guest
Re: My first custom object
« Reply #20 on: July 12, 2009, 01:00:58 AM »
well, have tried to post something about preventing the FILLETing (it works but now have to fix the transFormby() hmmm)... but simple can't type, will try tomorrow.

g-nite

Spike Wilbury

  • Guest
Re: My first custom object
« Reply #21 on: July 12, 2009, 11:47:13 AM »
Daniel,

I might need also the way to prevent the FILLETing too, and did a quick code and it does prevent the fillet, but now the the object (derived from an AcDbPolyline) cannot be MOVE because of the reuse of previous points... anyway can be used as start (maybe)

Code: [Select]
virtual Acad::ErrorStatus subOpen (AcDb::OpenMode mode);
virtual Acad::ErrorStatus subClose ();
Acad::ErrorStatus getPolyPointsAndCurvatures (AcDbPolyline* pline, AcGePoint3dArray& points, AcGeDoubleArray& curvatures);

Code: [Select]
static int numOfVerts = 0;
static AcGePoint3dArray points;
static AcGeDoubleArray curvatures;

Acad::ErrorStatus ZoneMarker::getPolyPointsAndCurvatures(AcDbPolyline* pline, AcGePoint3dArray& points, AcGeDoubleArray& curvatures)
{
Acad::ErrorStatus es = Acad::eOk;
AcGePoint3d p;
double c;

for (UINT i = 0; i < pline->numVerts(); i++)
{
pline->getPointAt(i,p);
pline->getBulgeAt(i,c);
if ((pline->normal()-AcGeVector3d::kZAxis).length() > 1E-6) c *= -1.0;
points.append(p);
curvatures.append(c);
}
if (pline->isClosed())
{
if (points.first() != points.last())
{
points.append(points.first());
curvatures.append(curvatures.first());
}
}
return es;
}

Acad::ErrorStatus ZoneMarker::subOpen (AcDb::OpenMode mode)
{
numOfVerts = this->numVerts();
getPolyPointsAndCurvatures(this, points, curvatures);
return (AcDbEntity::subOpen (mode)) ;
}

Acad::ErrorStatus ZoneMarker::subClose ()
{
if (isModified())
{
//acutPrintf(_T("\nOriginal vertices[%ld] vs[%ld]"), numOfVerts, this->numVerts()); // debug
for (UINT i = 0; i < numOfVerts; i++)
{
AcGePoint2d p(points[i].x, points[i].y);
this->setPointAt(i,p);
this->setBulgeAt(i,0.0);
}
numOfVerts = 0;
points.setLogicalLength(0);
curvatures.setLogicalLength(0);
}
return AcDbEntity::subClose();
}


And Dan, if you found an easy way on how to prevent the FILLETing - post it! :)


krasbog

  • Mosquito
  • Posts: 4
Re: My first custom object
« Reply #22 on: September 01, 2009, 04:18:36 PM »
Daniel , can you share the entire project code for Bricscad?

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6941
  • AKA Daniel
Re: My first custom object
« Reply #23 on: September 04, 2009, 05:51:50 AM »
Ha! I don't know what I did with that solution  :-o
as soon as I run across it, I will post it.