Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

jlink(visit all the components)

davidxing

New member
hello,


when I use jlink to visit all the components in assembly, I only can visit the first level components. if one component is also assembly, how to visit it's child? Thanks!!!!!


the code is as follows:


try {
komponenty = assembly.ListFeaturesByType(Boolean.TRUE, FeatureType.FEATTYPE_COMPONENT);
for (int i = 0; i < komponenty.getarraysize(); i++){
String komponent = komponenty.get(i).GetName().toString();

}
}
catch (jxthrowable x){

}
 
dear friend .,

try this

try {

Features asm_components== assembly.ListFeaturesByType(Boolean.TRUE, FeatureType.FEATTYPE_COMPONENT);
for (int i = 0; i < asm_components.getarraysize(); i++){
Feature asm_component =asm_components.get(i);
ComponentFeat ComponentFeature = (ComponentFeat )asm_component;
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
ModelDescriptor ModelDescriptor = ComponentFeature .GetModelDescr();
Model assmModel = session.RetrieveModel(ModelDescriptor);
Solid Solid = (Solid)assmModel;
ModelType ModelType = ModelDescriptor.GetType();</BLOCKQUOTE>
if (ModelType.equals(ModelType.MDL_ASSEMBLY)) {
//call same function recursively
}


}
}
catch (jxthrowable x){

}

Ajoy Varghese Mathew
 
thanks,


i have resolved this question using visit all the assemblies firstly, then visit thire children.


in fact, i want to get bom list in assembly or drawing. Dear ajoy or other friends,


could you give me some idear. thanks in advance.
 
You will not get any help from J/Link API for generating BOM ,you can do it by using vectors .collect levels and quantity while visiting through each model, this is little tricky , but i think u can do it. just see this ASM002.ASM tree & BOM generation in excel .


excel

Regards

Ajoy Varghese Mathew
 
dear Ajoy,


firstly, thank for your helpful.


You have told me to levels and quantity...


Could you tell me the details in code. I am a beginner in proe and Jlink. You only need general coding.


waiting for you replay...
 
dear friend ,
first u make use of vectors to create a bom of your own , if u are feeling any problem , send me that code , this is the right way to solve .

Regards,
Ajoy Varghese Mathew
 
Dear Ajoy,


My code is as following, I visit all the components according to your opinion.


package proe;


import javax.swing.JFrame;
import javax.swing.JOptionPane;


import com.ptc.cipjava.jxthrowable;
import com.ptc.pfc.pfcAsyncConnection.AsyncConnection;
import com.ptc.pfc.pfcAsyncConnection.pfcAsyncConnection;
import com.ptc.pfc.pfcModel.Model;
import com.ptc.pfc.pfcModel.ModelDescriptor;
import com.ptc.pfc.pfcModel.ModelType;
import com.ptc.pfc.pfcModel.pfcModel;
import com.ptc.pfc.pfcSession.Session;


//
import com.ptc.pfc.pfcSolid.Solid;
import com.ptc.pfc.pfcFeature.*;
import com.ptc.pfc.pfcComponentFeat.*;
import com.ptc.pfc.pfcFamily.FamilyTableRow;
import com.ptc.pfc.pfcBase.*;
import com.ptc.pfc.pfcSelect.*;
import com.ptc.pfc.pfcModelItem.*;
import com.ptc.pfc.pfcAssembly.*;
public class proeApi {
private static Session cursession;
private static String proe_cmd = "";
private String rtnlist="";
//static {
//
 
Here is an example on how to send the BOM data directly from Pro/Engineer to Excel:


[url]http://inversionconsulting.blogspot.com/2008/04/proweblink-s ending-your-proengineer.html[/url]



Pro/WebLink is better suited to Excel data transfers because it is COM based. It
can communicate directly with Excel, Word, or any other COM accesible application.
The API is very similar to J-Link. If you have gotten familiar with J-Link, then
Pro/WebLink is not hard to pick up. I use it as a rapid prototyping environment
for applications.
 

Sponsor

Back
Top