For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

entity error

Derrek Curtis's picture

I am building a Viewer on top of a MFC application.  I have OpenCascade installed and running in a MFC view.  I am running into problems send geometry data to the view via a MFC document. If I create geometry from with the document everything is fine.  But if I call for the creation of the same geometry from a different file I get a  Standard_Transient* ControlAccess() ​error the return type is entity.  attached is the code for the circle creation:  

void CVMS7Doc::DrawTestCircle()
Standard_Real x;
Standard_Real y;
Standard_Real z;
Standard_Real rad;
rad = 100;
gp_Dir dir(0,0,1); // you can change this
gp_Pnt point(100,200,300);
gp_Circ circle(gp_Ax2( point, dir),rad);
BRepBuilderAPI_MakeEdge makeEdge(circle);
Handle(AIS_Shape) shape = new AIS_Shape(TopoDS_Edge());
shape ->Set(makeEdge.Edge());

myAISContext->Display(shape , 1);

}If I call this from within the DOC it works fine but not from a second file:

void draw_circle_view( _FEATURE *feature, double red, double green, double blue )
 double x = feature->element[ _X_LOC ];
 double y = feature->element[ _Y_LOC ];
 double z = feature->element[ _Z_LOC ];
 double radius = feature->element[ _RADIUS ];

 if( !feature->part_coordinates ) {
  machine_to_part_coordinates(&x, &y, &z);

 pRender->DrawOglCircle(x, y, 0.0, radius, feature, red, green, blue);


}  let me know if you see anything That I have done wrong

Forum supervisor's picture

Hello Derrek,

What I see is that you create AIS_Shape object with a NULL edge which is not very logical. I'd rewrite your code like this:

BRepBuilderAPI_MakeEdge makeEdge(circle);
TopoDS_Shape edge = makeEdge.Edge();
Handle(AIS_Shape) shape = new AIS_Shape(edge);
myAISContext->Display(shape , 1);

If that won't help, we might propose you deeper analysis in the frames of a support program, for example.

Please, contact us to know more about our support offer.

Best regards,

Forum supervisor

Derrek Curtis's picture

Hello, Im getting no ware with this.  No matter what I try I get the same error message:

 //! Returns non-const pointer to referred object
  Standard_Transient* ControlAccess() const
    return entity;

Does the entity need to be initalized on order to be used?   Any suggestions would be great.


Forum supervisor's picture

Hello Derrek,

Actually, at what line of your code the exception is thrown?

May it be that the variable pOpenDoc is not properly initialized?

Best regards,

Forum supervisor

Derrek Curtis's picture


myAISContext->Display(shape , 1); right after this line I get the error.  pOpenDoc appears to initialized properly.  Im a lttle confused on why I am calling for drawing in the DOC component and not the View side.  I also have many views.  It would not surprized if I have a " plumbing problem".  If I call  the draw command from the constructor of the DOC everything works.  I am migrating from a working OpenGL renderer.



Kirill Gavrilov's picture

Hello Derek,

it is difficult following you code and give some advices, since too many items become unclean.

I suppose you do understand, that mixing two OpenGL viewers requires extra attention, and may result have a lot of side effects if not done correctly (although, unlikely in the way you are currently experienced)?
There are two ways for embedding custom OpenGL code - through implementing custom OpenGl_Element, or through overriding redraw routines - otherwise result might be undefined, especially if custom OpenGL code has own context initialization routines / camera / projection matrices / OpenGL state management.

Anyway, I would start from simplifying the code and excluding as much functionality as possible - ideally by providing reproducible code samples or at least providing complete call stack.

Derrek Curtis's picture

Hello, The error appears to be coming from TS_Shape location. I cant seem to figure out why this is happening.  Is there away to set it a 0,0,0? Derrek

Kirill Gavrilov's picture

Setting a zero location is straightforward - just calling TopoDS_Shape::Location (TopLoc_Location()).
How do you do this now?

Derrek Curtis's picture

The problem appears to be in the way Im using The CDocument Class.  When the program starts up the DOC constuctor is creating myAISContent.  However when I try to add geometry to to the Document  my AISContext is no longer intialized. I have looked at all the available samples and not found a solution.

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.