Thank you David, boy do I feel dumb. That seems to have fixed it.
--
David Bartliff wrote:
> Bill,
> I don't think you are allocating the correct memory.
> Unless I'm having a brainstorm Adesk::UInt32 numVerts = pPline->numVerts();
> will return the number of vertices and the size of the array to allocate.
> i.e. AcGePoint3d *verts = new AcGePoint3d[numVerts];
> If you have 6 vertices, then you need to allocate enough memory for 6. 5 is
> the upper limit on the index, not the size to allocate.
>
> "Bill Wright" wrote in message
> news:3D6E388A.27C06316@archsky.com...
> > This is another shot at my last post about pointer problems. This time I
> > am including the function that is passing the pointer because I think
> > this is where the real problem is originating. What I'm trying to do is
> > pass an array of points to my object then that object will ultimately
> > use those points to set up more points in the object. I can run the
> > insert function several times without trouble then I will crash.
> > Sometimes if I unload my program and reload it it will crash after only
> > running it a few times. Obviously I'm new at this so any help would be
> > appreciated.
> >
> >
> > this is my arx command function:
> > void InsertMyObject()
> > {
> > AcDbDatabase *pCurDb;
> > AcDbObjectId LinId;
> > Acad::ErrorStatus es;
> >
> > //get the current database
> > pCurDb = acdbHostApplicationServices()->workingDatabase();
> >
> > AcDbObjectId SectionPolyId;
> > int GsMark;
> > AcDbPolyline *pPline;
> > AcGePoint3d Vertex;
> >
> > //get the object ID of the polyline
> > es = getObjectAndGsMarker(SectionPolyId, GsMark);
> >
> > //open the pline for reading
> > acdbOpenObject(pPline, SectionPolyId, AcDb::kForRead);
> >
> > // Set up the vertices.
> > Adesk::UInt32 numVerts = pPline->numVerts();
> > AcGePoint3d *verts = new AcGePoint3d[(numVerts - 1)];
> >
> > for (int vertexNumber = 0; vertexNumber < numVerts; vertexNumber++)
> > {
> > es = pPline->getPointAt(vertexNumber, Vertex);
> > verts[vertexNumber] = Vertex;
> > }
> >
> > pPline->close(); // Finished with the pline header.
> >
> > MyDBXObject *pObj;
> >
> > pObj = new LPLineal;
> >
> > pObj->SetCrossSection(verts, numVerts);
> >
> > es = appendToBlockTable(pObj, LinId, ACDB_MODEL_SPACE, pCurDb);
> > if(es != Acad::eOk)
> > {
> > acutPrintf("\nError drawing My object!");
> > if(pObj)
> > {
> > delete pObj;
> > return;
> > }
> > }
> >
> > pObj->close();
> >
> > }
> >
> >
> > this is my dbx object that seems to cause problems:
> > void MyDBXObject::SetCrossSection(AcGePoint3d*& verts, Adesk::UInt32
> > numVerts)
> > {
> > AcGePoint3d location;
> > m_numStartSectionVerts = numVerts;
> > m_StartSectionVerts = verts;
> >
> > for (int vertexNumber = 0; vertexNumber < numVerts ; vertexNumber++)
> > {
> > location = m_StartSectionVerts[vertexNumber];
> > location.z = 10.00;
> > }
> > }
> >