Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
I need to extract the geometric tolerances that you see inside the geometric tolerancing blocks on Creo drawings, such as values for Flatness, Concentricity, etc. Looking at the Creo Object TOOLKIT java User's Guide under "Annotations: Annotation Featurs and Annotations>Accessing and Modifying Annotation Elements on page 241, it looks like there might be a way to do it. It shows wfcAnnotation.Annotation.GetAnnotationElement and wfcAnnotation.AnnotationElement.GetAnnotationType with one of the valid types = ANNOTATION_GTOL.
But that is as much help as it provides. Heaven forbid that it shows any examples of how to use it. I grepped the examples at
C:\Program Files\PTC\Creo 4.0\M030\Common Files\otk\otk_java\otk_java_examples
and
c:\Program Files\PTC\Creo 4.0\M030\Common Files\otk_java_free\otk_java_appls\jlinkexamples
for key words like "ANNOTATION_GTOL" and "GetAnnotationElement" and "GetAnnotationType" but came up empty.
So once again, I must ask the community for help. Anybody know how to do this?
I believe that there is no such example in the PTC examples.
The question what did you try already, because may be, you did in your code mostly the correct steps but for a particular function we have some issue. So in such cases when we do not have an example we need step by step to try to implement the desired functionality and investigate what is going wrong.
So last week I had an issue where I needed to select a symbol annotation (in part mode) and then I wanted to have the variable texts of it. And this was not working.
For the solution I needed to look in the "otk_javaug.pdf" - guide -> Chapter "
Version Compatibility :Creo Parametric and Creo Object TOOLKIT Java
So after starting the Java OTK with compatibility mode then it was able to get the var text of the symbol instance annotation:
… { try { l = new Logger( "log_OTK_JAVA_1.txt" ); l.write("Started"); l.write("==================================="); /*** this is the default way to get a session but there did not work all Session s = pfcGlobal.GetProESession(); *****/ Session s = pfcSession.GetCurrentSessionWithCompatibility(CreoCompatibility.C4Compatible); l.write("after getting session"); SelectionBuffer selectionBuffer = s.GetCurrentSelectionBuffer(); Selections selections = selectionBuffer.GetContents(); l.write("selectionBuffer.GetContents()"); for (int i = 0; i < selections.getarraysize(); i++) { l.write("work on selection number = "+i); WSelection selection = (WSelection) selections.get(i); if (selection.GetSelItem().GetType().getValue() == ModelItemType._ITEM_ANNOTATION_ELEM) { l.write("sit is ModelItemType._ITEM_ANNOTATION_ELEM"); ModelItem item =selection.GetSelItem(); com.ptc.wfc.wfcAnnotation.AnnotationElement annoElement = (com.ptc.wfc.wfcAnnotation.AnnotationElement) item; AnnotationType type = annoElement.GetAnnotationType(); l.write("annoElement.GetAnnotationType();"); com.ptc.wfc.wfcAnnotation.Annotation anno = annoElement.GetAnnotation(); l.write("com.ptc.wfc.wfcAnnotation.Annotation anno = annoElement.GetAnnotation();"); DetailSymbolInstItem sym = (DetailSymbolInstItem) anno; DetailSymbolInstInstructions my_sym_instrs=sym.GetInstructions(false);//asNames=false DetailVariantTexts myVars=my_sym_instrs.GetTextValues (); for (int a=0;a< myVars.getarraysize () ;a++) { DetailVariantText myVarTxt=myVars.get (a); l.write("a["+a+"] GetPrompt="+myVarTxt.GetPrompt()+" GetValue="+myVarTxt.GetValue()); } } } l.write("==================================="); l.write("Finished"); …. .... So testing the code abole - created the following log: [2018-07-13 18:21:26.401] Started [2018-07-13 18:21:26.411] =================================== [2018-07-13 18:21:26.412] after getting session [2018-07-13 18:21:26.415] selectionBuffer.GetContents() [2018-07-13 18:21:26.416] work on selection number = 0 [2018-07-13 18:21:26.424] sit is ModelItemType._ITEM_ANNOTATION_ELEM [2018-07-13 18:21:26.426] annoElement.GetAnnotationType(); [2018-07-13 18:21:26.429] com.ptc.wfc.wfcAnnotation.Annotation anno = annoElement.GetAnnotation(); [2018-07-13 18:21:26.436] a[0] GetPrompt=x GetValue=1 [2018-07-13 18:21:26.436] =================================== [2018-07-13 18:21:26.436] Finished
This is my experience about getting an annotation in 3d mode (part or assembly)
In 2d mode (drawings) - you can access some types of annoation in J-Link (OTK Java is not required) but so far I know the gtol was not implemented in JLink.
So I believe (my suggestion - I did not tested it), in the example above you need also to check the type
(AnnotationType type = annoElement.GetAnnotationType(); and check if the "type" is ANNOTATION_GTOL)
And then you could cast it to wfcGTol object, where then you can use the all method of this object:
• wfcGTol.GTol.GetGTolName
• wfcGTol.GTol.GetTopModel
• wfcGTol.GTol.GetCompositeSharedReference
• wfcGTol.GTol.GetComposite
• wfcGTol.GTol.GetDatumReferences
• wfcGTol.GTol.GetIndicators
• wfcGTol.GTol.GetReferences
• wfcGTol.GTol.GetGTolType
• wfcGTol.GTol.IsBoundaryDisplay
• wfcGTol.GTol.GetUnilateralModifier
• wfcGTol.GTol.GetValueString
• wfcGTol.GTol.IsAllAround
• wfcGTol.GTol.IsAllOver
• wfcGTol.GTol.IsAddlTextBoxed