Custom Entity with embedded solids

Custom Entity with embedded solids

msgilgen
Participant Participant
1,630 Views
4 Replies
Message 1 of 5

Custom Entity with embedded solids

msgilgen
Participant
Participant

Hi 

We will change our custom entities from wireframe objects (polylines and text included) to custom entities with embedded solid objects (text + polyline + AcDb3dSolid objects)

I have to produce a simple prototype project with just a simple square / box...

I will test following options --> The entity should be able to manage following actions

MOVE / ROTATE / COPY / WBLOCK / EXPLODE (with EXPLODE the TEXT / POLYLINE / SOLID objects should be normal AutoCAD objects)

Ive used as template the embedded solid posts with the solid sphere

At the moment I can save and reopen the DWG with my solid custom entities, I can also copy the entities...

but Im not able to move the entities properly... So my transformBy function of the entity is probably not good.

Following happens after the using of MOVE command 

Entities Polyline Text objects are moving as expected to the new position, but the embedded solid objects are still

at the old position (viewing in realistic viewport) the solid embedded objects come up correctly to the new position after a SAVE and Reopen the Drawing or after the command REGEN3 (which is for correct solid objects graphic)

 

Can somebody help/supporting me in that??

A small template project of a custom entity with embedded solid objects would be great

Attached my cpp and h files for my custom entity + screenshots 

Any help/support would be great2D-Wireframe-View.JPGRealistic-View.JPG

Thanks very much in Advance

0 Likes
Accepted solutions (2)
1,631 Views
4 Replies
Replies (4)
Message 2 of 5

tbrammer
Advisor
Advisor
Accepted solution

Try to call   this->recordGraphicsModified(true);

in your method FFOLMAST::subTransformBy(const AcGeMatrix3d& xform).

 

It seems your member variables

 

    AcGePoint3d  mCenter;
    AcGeVector3d mOrient;
    AcGeVector3d mNormal;

 

describe the position and orientation of your entity.

Why don't you use AcGeMatrix3d instead? This is the "natural" way to describe an entity coordinate system:

 

AcGeMatrix3d mTrans;

mTrans.setCoordSystem(
    mCenter,
    mOrient,                       // xAxis
    mNormal.crossProduct(mOrient), // yAxis
    mNormal                        // zAxis
);

 

Than you could write your drawing method like this:


FFOLMAST::subWorldDraw(AcGiWorldDraw * wd)
{
   wd->geometry().pushModelTransform(mTrans);
   wd->geometry().draw(solid);
   wd->geometry().popModelTransform();
}

 

You can create your solid once and you don't need to re-create it to transform your entity.

And simply:

 

FFOLMAST::subTransformBy(const AcGeMatrix3d& xform) {

   assertWriteEnabled();

   mTrans.preMultBy(xform);

   recordGraphicsModified(true);

}

 

This is just a proposal. I don't know the purpose behind your code. But if your entity is supposed to have its own coordinate system (ECS) I would recomment to do it like this.

 


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.

Message 3 of 5

msgilgen
Participant
Participant
Hi thanks very much for your reply
Will try this later...
You are wrigth the entity should have its own coord system
Will create the solid once by setting up the entity
One thing is not clear for me
Where shall i place the mtrans function?
Are you able to provide me a small solution of embedded solid just an extruded square the .cpp for it?
Thanks again very much
0 Likes
Message 4 of 5

msgilgen
Participant
Participant

I mean where shall I use the mTrans.setCoordsystem function?

0 Likes
Message 5 of 5

tbrammer
Advisor
Advisor
Accepted solution

My idea was to replace the three member variables  mCenter, mOrient, mNormal with the matrix mTrans.

When you read mCenter, mOrient, mNormal in dwgIn() you can call mTrans.setCoordsystem().

This was just an idea. I don't know whether this makes sense for your requirements.


Thomas Brammer ● Software Developer ● imos AGLinkedIn
If an answer solves your problem please [ACCEPT SOLUTION]. Otherwise explain why not.