cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Create multiple Annotation Features using ProToolkit

sharon.barber
1-Visitor

Create multiple Annotation Features using ProToolkit

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. */



This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
6 REPLIES 6


Hi Sharon -

I am also working with 3D Annotations. I have end users running both WF4
and
WF5, so I am building on WF4 for now.

> 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'm assuming that you've already figured out the confusing relationships
between annotation features, annotation elements and annotations. For
those
who haven't done that yet, an annotation feature is a "container" for one
or
more annotation elements. Each annotation element contains a single
annnotation
(note, symbol, etc) and any model references for that annotation.

I haven't run anything that made more than one call to
ProAnnotationfeatCreate()
in a single execution. What's peculiar about this call is that its only
inputs
are a ProSelection of the model and a boolean value to specify UI
interaction.
Which means that your repeated calls are using the same input values each
time.

Does your function assign a name to the annotation after you create it?
You can do that with ProModelitemNameSet(). If that doesn't work, I
suggest
you open a support call with PTC. They have been very helpful to me in
getting
to the bottom of issues like this.

|+| M a r k |+|

Mark Stallard
Rapid Response Development
information Solutions
Integrated Defense Systems
Raytheon Company




(business)
+1.339.645.6423
(cell)
+1.617.331.5443
(tie line)
224.6423

-



235 Presidential Way
Woburn, MA 01801-1060
www.raytheon.com


Raytheon Sustainability

This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this message
in error, please so advise the sender by reply e-mail and delete this
message. Thank you for your cooperation.










Sharon -

Sorry, I didn't see you code at the bottom before I replied.
You seem to be writing this correctly. I recommend you open a
support call at PTC.

|+| M a r k |+|

Mark Stallard
Rapid Response Development
information Solutions
Integrated Defense Systems
Raytheon Company




(business)
+1.339.645.6423
(cell)
+1.617.331.5443
(tie line)
224.6423

-



235 Presidential Way
Woburn, MA 01801-1060
www.raytheon.com


Raytheon Sustainability

This message contains information that may be confidential and privileged.
Unless you are the addressee (or authorized to receive mail for the
addressee), you should not use, copy or disclose to anyone this message or
any information contained in this message. If you have received this message
in error, please so advise the sender by reply e-mail and delete this
message. Thank you for your cooperation.









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


FV
17-Peridot
17-Peridot
(To:sharon.barber)

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

FV
17-Peridot
17-Peridot
(To:sharon.barber)

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


Announcements


Top Tags