I need help to create a shared cell definition using the content in a drawing file. The drawing file is a dwg and contains 3D data.
I have used the following code (some parts omitted) and it creates a definition but it does not have any valid content. The file opens ok and all functions return SUCCESS.
...
mdlWorkDgn_openFile(&modelPt, &fileFormat, &threeD, "FILEPATH", NULL, TRUE);
mdlSharedCell_createDefinitionElement(&sharedDefElem, cellName, FALSE);mdlElmdscr_new( &cellHeaderPt, NULL, &sharedDefElem );
scanCritPt = mdlScanCriteria_create();mdlScanCriteria_setModel (scanCritPt, modelPt);mdlScanCriteria_setReturnType (scanCritPt, MSSCANCRIT_ITERATE_ELMDSCR ,FALSE,TRUE );mdlScanCriteria_setElementCategory (scanCritPt,ELEMENT_CATEGORY_GRAPHICS);mdlScanCriteria_setElmDscrCallback(scanCritPt, CreateCellDefCallb, (void *)cellHeaderPt);mdlScanCriteria_scan (scanCritPt, NULL, NULL,NULL); // Returns END_OF_DGNmdlSharedCell_addDefinitionElements( cellHeaderPt, &cellRot, &cellOrigo );
The callback:
static int CreateCellDefCallb(MSElementDescr *edP, void * targetDescrPt, ScanCriteria *scP){ MSElementDescrP copyDescrP; mdlElmdscr_duplicate (©DescrP, edP); mdlElmdscr_addToChain((MSElementDescrP)targetDescrPt, copyDescrP); return SUCCESS;}
Thanks in advance!
I would simplify the process:
Regards, Jon Summers LA Solutions
Reference the DWG file as a cell library and just place the cell as a shared cell via the settings. I have done this for other applications.
HTH,
mark anderson [Bentley]
Visit me at https://communities.bentley.com/communities/other_communities/bentley_innovation/default.aspx
Thank you both for the prompt replies.
I have used Jon's solution as it gives me the opportunity to change the name of the shared cell before adding it to the drawing. I attached the dwg as a cell library directly though as mark suggested.
Thanks again!