Unknown said:mdlElmdscr_add (*cellDP);
Where do you get that cell descriptor? Is it copied from a cell library?
Regards, Jon Summers LA Solutions
Hi Jon. Yes it is copied from a cell library using mdlCell_getElmdscr().
Kind regards,
Sedat AlisAEC Technology Inc.
Unknown said: Name doesn't contain PP but it is MSElementDescr **cellDP
Name doesn't contain PP but it is MSElementDescr **cellDP
That doesn't look right to me. You should obtain an element descriptor from somewhere, then pass it to that function by address. For example:
MSElementDescr* pElm = NULL; if (0 < mdlElmdscr_read (&pElm, ..., ...)) { mdlModify_elementDescr2 (&pElm, ..., ... ); } mdlElmdscr_freeAll (&pElm);
"MSElementDescr **cellDP" is passed as a parameter into that function.
Unknown said:Yes it is copied from a cell library using mdlCell_getElmdscr()
A line of code is worth 1,000 words. Why not post a larger snippet of code that shows the fuller picture...How do you obtain a cell descriptor from a cell library?
Unknown said: How do you obtain a cell descriptor from a cell library?
How do you obtain a cell descriptor from a cell library?
char activeCell[MAX_CELLNAME]; MSWChar wActiveCell[MAX_CELLNAME]; int status; MSElementDescr *cellDescrP=NULL; char fullName[MAXFILELENGTH],libName[MAXFILELENGTH]; strcpy(libName,"my.cel"); fullName[0]=0; // Detach library first, to prevent any problem from light settings status = mdlCell_attachLibrary (NULL, NULL, NULL, FALSE); status = mdlCell_attachLibrary (fullName, libName, NULL, TRUE); mdlParams_getActive (activeCell, ACTIVEPARAM_CELLNAME); // if there is no active cell then return if(activeCell[0] == 0) return; mdlCnv_convertMultibyteToUnicode(activeCell,-1,wActiveCell,sizeof(wActiveCell)/sizeof(MSWChar)); status = mdlCell_getElmDscr (&cellDescrP, NULL, NULL, NULL, TRUE, NULL, NULL, 0, FALSE, TRUE, wActiveCell, NULL); if(status==SUCCESS) { cellDescrP->h.isValid=FALSE; mdlElmdscr_validate (cellDescrP, ACTIVEMODEL); }
That looks OK. If you're modifying or replacing elements in that descriptor, do so between clearing the isValid flag and calling mdlElmdscr_validate.
You are correctly setting updateMasterFile to True, which will copy levels etc. from the library to the active model as required.
What happens if you add the cell to the active model without modifying it?
I found the reason. If I use below code to disable undo (because I also add a database portion related to the element descriptor with mslink) after mdlElemdscr_add(), element descriptor isn't displayed !
mdlUndo_setActive(FALSE);mdlUndo_setActive(TRUE);
But why?
Instead of using mdlUndo_xxx functions, I used below function and the problem is solved.
mdlInput_sendKeyin( "SET UNDO OFF;SET UNDO ON", 0, INPUTQ_EOQ, ustnTaskId);
Element descriptors are displayed normally now after added to design file.
Sedat
The transaction manager records changes to the file and takes care of updating the display. It doesn't do this when you disable undo because it is assumed it's not an interactive session so there is no reason to keep the screen in synch.
-B
Thank you Brien. Thank you Jon.
Ahmet,
if you like to asure that your changes are treated as one, use mdlUndo_startGroup and mdlUndo_endGroup to encapsulate your changes.
Install a callback for the Undo Command (mdlChangeTrack...) or a dependency to monitor Changes and possibly clear your database entry if the element is deleted.
Michael
Thank you Michael.