Skip to main content
12-Amethyst
August 24, 2023
Question

Note attached to a surface.

  • August 24, 2023
  • 1 reply
  • 1631 views

SO I'm making a project to calculate the surface areas of a sheet metal part that has a surface finish, two types "finish1" and "finish2", but I only have access to the free java object toolkit. I know I cannot use the surface finishes nor the annotations. I had an idea to attach a note of a specific type to a surface with a surface finish and then get the surface its attached to then get its area. Is this possible? I've tried GetAttachment() as it is a DetailNoteItem and doing GetParent which  returns with the part which I think isn't helpful as i none of the model items from that are surfaces. Is there another way?

 

 

 

 

	//Surface Finishes
	private HashMap <String, Double> getFinishes(Solid solid){
		double finish1 = 0;
		double finish2 = 0;
		
		HashMap <String, Double> finishes = new HashMap <String, Double>();
		try {
		
		ModelItems modelItems = solid.ListItems(ModelItemType.ITEM_DTL_NOTE);
		
		for (int i = 0; i<modelItems.getarraysize(); i++) {
			
			ModelItem modelItem = modelItems.get(i);
			
			printMsg("modelItem: " + modelItem.GetName());
			DetailNoteItem detailNoteItem = (DetailNoteItem) modelItem;
			DetailTextLines textLines = detailNoteItem.GetTextLines(DetailTextDisplayOption.DISPMODE_NUMERIC);
				
			for (int j=0;j<textLines.getarraysize();j++) {
				
				DetailTextLine textLine = textLines.get(j);
				DetailTexts texts = textLine.GetTexts();
										
				for (int k =0;k<texts.getarraysize();k++) {
					
					DetailText text = texts.get(k);
					String note = text.GetText();
					//printMsg("note: " + note);
					if (modelItem.GetName().equals("Note_24")){
						printMsg("Note: " + note);
						
						
						try {
						
						DetailAttachment detailAttachment = detailNoteItem.GetAttachment();
						printMsg("got attachment");
						printMsg("Attachment: "+ detailAttachment);
						
						}
						catch (jxthrowable e) {
							e.printStackTrace();
						}
						
						
						try {
						
						Parent parent = detailNoteItem.GetDBParent();
						printMsg("got parent");
						printMsg("Parent: " + parent);
						
						Part parentPart = (Part) parent;
						
						ModelItems parentModelItems = parentPart.ListItems(null);
						
						for (int l = 0; l<parentModelItems.getarraysize();l++) {
							ModelItem parentModelItem = parentModelItems.get(l);
							//printMsg("modelItem: "+ parentModelItem);
							
						}
						}
						catch (jxthrowable e) {
							e.printStackTrace();
						}
						
						
						try {
						
						Child child = detailNoteItem.GetChild(null);
						printMsg("got child");
						printMsg("Child: " + child);
						
						}
						catch (jxthrowable e) {
							e.printStackTrace();
						}
										
					}
				}
			}
		}
		
		finishes.put("finish1",finish1);
		finishes.put("finish2",finish2);
		
		}catch (jxthrowable e) {
			e.printStackTrace();
		}
		return finishes;
	
	}

 

 

 

 

 

 

 

1 reply

tbraxton
22-Sapphire II
22-Sapphire II
August 24, 2023

Have you considered datum analysis features within the model to calculate the areas? These features include parameters for the surface area that can be used in a note.

12-Amethyst
August 25, 2023

I have not tried it, I'm still new to Creo so I've never used them before and the article To_Create_an_Analysis_Feature doesn't seem too helpful as I don't know what definition or type I should use. would it be okay for you to give me a quick run down on the basics of these? Thanks!