TheSwamp

Code Red => ARX Programming => Topic started by: It's Alive! on May 02, 2009, 11:17:21 AM

Title: My first custom object
Post by: It's Alive! on May 02, 2009, 11:17:21 AM
Whoopee  :roll:

Title: Re: My first custom object
Post by: Spike Wilbury on May 02, 2009, 11:22:41 AM
:)

What it does?
Title: Re: My first custom object
Post by: It's Alive! on May 02, 2009, 11:41:32 AM
try it  :laugh:
Title: Re: My first custom object
Post by: Spike Wilbury 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
Title: Re: My first custom object
Post by: It's Alive! 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
Title: Re: My first custom object
Post by: Spike Wilbury 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)) ;
}
Title: Re: My first custom object
Post by: It's Alive! 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 )
Title: Re: My first custom object
Post by: ahlzl on May 03, 2009, 07:02:48 AM
Daniel , can you share code?
Title: Re: My first custom object
Post by: It's Alive! 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.

Title: Re: My first custom object
Post by: It's Alive! on May 06, 2009, 10:22:37 AM
And with the change of a couple of paths

Title: Re: My first custom object
Post by: Spike Wilbury on May 06, 2009, 11:29:02 AM
you are da' man Danielito....  :-P

(didn't know they have also custom objects.... good)
Title: Re: My first custom object
Post by: MP on May 06, 2009, 11:31:40 AM
And with the change of a couple of paths ...

Noice! :D
Title: Re: My first custom object
Post by: ahlzl on May 07, 2009, 09:52:00 AM
success !

thanks Daniel again.
Title: Re: My first custom object
Post by: Spike Wilbury 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.
Title: Re: My first custom object
Post by: It's Alive! on May 26, 2009, 05:43:50 AM
Interesting! Is there a way I can protect my entity from such malicious attacks?
Title: Re: My first custom object
Post by: Spike Wilbury 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.
Title: Re: My first custom object
Post by: It's Alive! 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...  :-)
Title: Re: My first custom object
Post by: It's Alive! on July 11, 2009, 08:44:18 PM
Hey LE, how do I prevent the Trim command from cutting into my opbject?   :-)
Title: Re: My first custom object
Post by: Spike Wilbury 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.

Title: Re: My first custom object
Post by: It's Alive! on July 11, 2009, 11:38:23 PM
Great, Thank you!

I will give it a shot :-)
Title: Re: My first custom object
Post by: Spike Wilbury 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
Title: Re: My first custom object
Post by: Spike Wilbury 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! :)

Title: Re: My first custom object
Post by: krasbog on September 01, 2009, 04:18:36 PM
Daniel , can you share the entire project code for Bricscad?
Title: Re: My first custom object
Post by: It's Alive! 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.