Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
I am trying to use ProToolkit to create annotation features (Toolkit for 3D Drawings license). I am calling a function 'InsertAnnotationFeature' repeatedly, once for each annotation feature I need to insert. In my test case, I have to add several annotation features (8). The first time the function is called, it works fine. However, the next call to the function locks up (crashes) Pro/E on the ProAnnotationfeatCreate API.I tried adding a couple of different things at the bottom of the function to see if that made a difference (a repaint and a ProSelectionFree), but the crash still occurred. Has anyone had problems with the function to create an annotation feature?
This particular test case uses Wildfire 5, as the testfile was generated in WF5. In general, this development effort is done simultaneously in WF4 and WF5. (We will be expanding this to Creo1 and 2 in the next month).
The Insert function is shown below. Any suggestions as to why this function might be causing Pro/E to crash/lockup would be helpful?
Regards,
Sharon Barber
ProError CMBDCadInterface::InsertAnnotationFeature(shared_ptr<cmapannotfeat> pAnnotFeat)
{
ProMdl proModel;
ProModelitem proModelItem;
// get current model and create a model item from model. Then select that model.
if (err == PRO_TK_NO_ERROR) err = ProMdlToModelitem(proModel, &proModelItem);
// allocate the new annotation feature (selection is model, and boolean says to NOT bring up the User Interface, but to automaticallty generate a single general annotation element
// change the name of this new feature
/** Additional code to add the desired annotation elements (e.g. notes, symbols) will be inserted here. */
Hi Mark,
Just wanted to give you a quick update. I held off putting in a report until I had a chance to test on Creo 1. (Which would have done 2 weeks ago, but our conversion from trial to permanent advanced licenses had some setbacks) . Anyway, in Creo1, the code worked as written and I got all the annotation features. Do you know if PTC is accepting and fixing issues detected in Wildfire 4 and Wildfire 5? The product we are working on is currently being developed in Pro/Engineer beginning with Wildfire 4 and I would really love to have annotation features included in all the versions since Wildfire is still widely used.
Thanks again for your earlier response.
Sharon
Hi all,
Sharon,
I would take a look at GetBuffer. This function is from CString. ProModelitemNameSet requires ProName.
Feliks.
In Reply to Sharon Barber:
I am trying to use ProToolkit to create annotation features (Toolkit for 3D Drawings license). I am calling a function 'InsertAnnotationFeature' repeatedly, once for each annotation feature I need to insert. In my test case, I have to add several annotation features (8). The first time the function is called, it works fine. However, the next call to the function locks up (crashes) Pro/E on the ProAnnotationfeatCreate API.I tried adding a couple of different things at the bottom of the function to see if that made a difference (a repaint and a ProSelectionFree), but the crash still occurred. Has anyone had problems with the function to create an annotation feature?
This particular test case uses Wildfire 5, as the testfile was generated in WF5. In general, this development effort is done simultaneously in WF4 and WF5. (We will be expanding this to Creo1 and 2 in the next month).
The Insert function is shown below. Any suggestions as to why this function might be causing Pro/E to crash/lockup would be helpful?
Regards,
Sharon Barber
ProError CMBDCadInterface::InsertAnnotationFeature(shared_ptr<cmapannotfeat> pAnnotFeat)
{
ProMdl proModel;
ProModelitem proModelItem;
// get current model and create a model item from model. Then select that model.if (err == PRO_TK_NO_ERROR) err = ProMdlToModelitem(proModel, &proModelItem);
// allocate the new annotation feature (selection is model, and boolean says to NOT bring up the User Interface, but to automaticallty generate a single general annotation element
// change the name of this new feature
/** Additional code to add the desired annotation elements (e.g. notes, symbols) will be inserted here. */
Feliks,
Throughout our code, we had used the ProModelitemNameSet to rename various items and in each case, we used the GetBuffer(). But I decided to take your suggestion and look more closely at that line of code.. I commented out the setting of the name, and sure enough, all the annotations were successfully added. So I followed up by trying to see what method I could use to change the name of the newly created Annotation feature. Absolutely nothing worked until I did a brute force work-around. I grabbed the last feature generated and used that last feature in the ProModelitemNameSet. Although this is quite sloppy looking code, it did work. The issue was resolved in CREO1 as the original code worked as written.
Thanks for the suggestion that helped me to isolate the problem and find a solution.
Regards,
Sharon
Hi all,
Sharon,
Obviously I don't know the layout of your AnnotFeat class. Assuming, you are using wide character string to storeannotation feature name
and you are controling the length of the stored string to be less or equalto (PRO_NAME_SIZE - 1).
Instead of :
// change the name of this new feature
try this:
{
int l = -1;
l = _snwprintf( wname, PRO_NAME_SIZE - 1, L"%ls", pAnnotFeat->GetAnnotFeatName().GetBuffer());
{
}
Feliks.
In Reply to Sharon Barber:
Feliks,
Throughout our code, we had used the ProModelitemNameSet to rename various items and in each case, we used the GetBuffer(). But I decided to take your suggestion and look more closely at that line of code.. I commented out the setting of the name, and sure enough, all the annotations were successfully added. So I followed up by trying to see what method I could use to change the name of the newly created Annotation feature. Absolutely nothing worked until I did a brute force work-around. I grabbed the last feature generated and used that last feature in the ProModelitemNameSet. Although this is quite sloppy looking code, it did work. The issue was resolved in CREO1 as the original code worked as written.
Thanks for the suggestion that helped me to isolate the problem and find a solution.
Regards,
Sharon