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

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
My first custom object
« on: May 02, 2009, 11:17:21 AM »
Whoopee  :roll:


Spike Wilbury

  • Guest
Re: My first custom object
« Reply #1 on: May 02, 2009, 11:22:41 AM »
:)

What it does?

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
Re: My first custom object
« Reply #2 on: May 02, 2009, 11:41:32 AM »
try it  :laugh:

Spike Wilbury

  • Guest
Re: My first custom object
« Reply #3 on: May 02, 2009, 11:57:53 AM »
try it  :laugh:

I see and not bad :)


The first time I tried - I open AutoCAD 2009 and load the DBX, then I open the Drawing1.dwg and did not display anything, until I changed the name, but later I tried again and it was displaying on your original Drawing1.dwg

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
Re: My first custom object
« Reply #4 on: May 02, 2009, 12:09:45 PM »
Thanks, I guess I should have named the drawing.

It took me a little while to figure out how to manipulate the grips, all the samples show using

virtual Acad::ErrorStatus moveGripPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset);

I had to override and return Acad::eNotImplemented on this function

virtual Acad::ErrorStatus moveGripPointsAt( const AcDbVoidPtrArray& gripAppData,const AcGeVector3d& offset, const int bitflags);

to get my grips to work using the older method

Spike Wilbury

  • Guest
Re: My first custom object
« Reply #5 on: May 02, 2009, 12:35:17 PM »
Thanks, I guess I should have named the drawing.

It took me a little while to figure out how to manipulate the grips, all the samples show using

virtual Acad::ErrorStatus moveGripPointsAt(const AcDbIntArray& indices,const AcGeVector3d& offset);

I had to override and return Acad::eNotImplemented on this function

virtual Acad::ErrorStatus moveGripPointsAt( const AcDbVoidPtrArray& gripAppData,const AcGeVector3d& offset, const int bitflags);

to get my grips to work using the older method

Is your custom object derived from AcDbPolyline ?

If it is, you can use:

Code: [Select]
Acad::ErrorStatus XXXXXXXXX::moveGripPointsAt (
const AcDbVoidPtrArray &gripAppData, const AcGeVector3d &offset,
const int bitflags
) {
assertWriteEnabled () ;

//----- If you return eNotImplemented here, that will force AutoCAD to call
//----- the older getGripPoints() implementation. The call below may return
//----- eNotImplemented depending of your base class.
return ([color=red]AcDbCurve[/color]::moveGripPointsAt (gripAppData, offset, bitflags)) ;
}

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
Re: My first custom object
« Reply #6 on: May 03, 2009, 12:59:13 AM »
Hey LE,

Have you seen any examples using the new method? I wasnít sure how to keep track of the index, also it might be cool to mess around with the glyphs, (little happy faces or something )

ahlzl

  • Guest
Re: My first custom object
« Reply #7 on: May 03, 2009, 07:02:48 AM »
Daniel , can you share code?

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
Re: My first custom object
« Reply #8 on: May 04, 2009, 11:00:16 AM »
Daniel , can you share code?

Here is the source for the custom object, itís not done yet.
The finished version is going to have special constructors and stuff for the app its going into.


It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
Re: My first custom object
« Reply #9 on: May 06, 2009, 10:22:37 AM »
And with the change of a couple of paths


Spike Wilbury

  • Guest
Re: My first custom object
« Reply #10 on: May 06, 2009, 11:29:02 AM »
you are da' man Danielito....  :-P

(didn't know they have also custom objects.... good)

MP

  • Seagull
  • Posts: 17400
Re: My first custom object
« Reply #11 on: May 06, 2009, 11:31:40 AM »
And with the change of a couple of paths ...

Noice! :D
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

ahlzl

  • Guest
Re: My first custom object
« Reply #12 on: May 07, 2009, 09:52:00 AM »
success !

thanks Daniel again.

Spike Wilbury

  • Guest
Re: My first custom object
« Reply #13 on: May 25, 2009, 01:15:06 PM »
Hi Daniel,

Don't know if you have noticed this.

Since your custom entity derived from an AcDbPolyline, it can be modified the rectangle form, for example when it is called PEDIT, and lost also the designed grips (for example if you use PEDIT - FIT - DECURVE).

I know this is for your personal use, just want it to comment about it.

Have fun.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6934
  • AKA Daniel
Re: My first custom object
« Reply #14 on: May 26, 2009, 05:43:50 AM »
Interesting! Is there a way I can protect my entity from such malicious attacks?

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: 6934
  • 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: 6934
  • 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: 6934
  • 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: 6934
  • 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.