Quantcast
Channel: PTC Community: Message List
Viewing all articles
Browse latest Browse all 11712

Re: Counting the numbers of perimeters using J-link

$
0
0

J-Link will get that for you. Those are Contours. You need to get the feature, get the surface, then get the contours.

 

Try This...It will let you interactively select a surface and outputs a message box with the Contour count.

It works on a standard part. Since I don't use sheetmetal parts very often we may need to tweek it a bit but I think it should work.

 
  try {
   //Get current Model
   Model model = curSession.GetCurrentModel();
  
   //Set Selection options
   //NOTE: See "Interactive Selection" in the jlinkug for options other than "surface"
   SelectionOptions options = pfcSelect.SelectionOptions_Create ("surface");
  
   //Set the maximum number of items that you can pick
   options.SetMaxNumSels (new Integer (1));
  
   //Run the method using the set options
   while(true){
   selectSurface(curSession, options);
   }
  } catch (jxthrowable e) {
   e.printStackTrace();

 

  }
  
}

  
private static void selectSurface(Session curSession, SelectionOptions options) throws jxthrowable{
   
    //Get the selection
    Selections selections = curSession.Select (options, null);
   
    //Cycle thru all items in the selection array (In this case its just 1)
    for(int j=0; j<selections.getarraysize();j++){
    
     //Select the current item
     ModelItem item = selections.get(j).GetSelItem();
    
     //get the surface feature
     Surface surf = (Surface)item;
    
     //get the surface type
     SurfaceType sfType = surf.GetSurfaceType();
    
     //Check surface Type & Visibility
     if (sfType == SurfaceType.SURFACE_PLANE && surf.GetIsVisible())
     {
      //If True List all Contours on the surface
      Contours contours = surf.ListContours();
     
      //Output to message box or wherever you want the info
      JOptionPane.showMessageDialog(null, "Type = " +sfType.getValue()+"\nContours = " +contours.getarraysize(),
        "Surface Contours",JOptionPane.INFORMATION_MESSAGE);
     
     }else {
      //If False skip or add a message if you like

 

     }
    }

 

  }
}

Contours_Page_1.jpgContours_Page_2.jpg


Viewing all articles
Browse latest Browse all 11712

Trending Articles