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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Extrude from BOM functionality is not working through customization

RaikarRaghu
12-Amethyst

Extrude from BOM functionality is not working through customization

The preference for the Part Structure Overridable Attribute in Windchill is related to the concept of excluding a component from the Bill of Materials (BOM). In SolidWorks, there is an option to exclude a part from the BOM, which allows the component to remain in the CAD structure within Windchill but not appear in the assembly's part structure.

If this preference is not enabled, Windchill will not track the excluded component and it will remain part of the BOM. To properly exclude a component from the part structure, you must check out and check in the CAD assembly. This ensures that the changes are reflected in the part structure and the excluded component does not appear in the BOM

 

1)through the manually do the checkout and checkin the CAD, the Extrude from BOM finctionality is working.

2)but if i do through programmatically checkout and checkin the CAD is happaning but the functionality is not working.

 

for checkout i wrote this:-

public static Workable doCheckOut(Workable epmDocument) {
    try {
        if (!RemoteMethodServer.ServerFlag) {
            return (Workable) RemoteMethodServer.getDefault().invoke("doCheckOut", AddtoWSChekin.class.getName(), null,
                new Class[]{EPMDocument.class}, new Object[]{epmDocument});
        }
        boolean enforce = SessionServerHelper.manager.setAccessEnforced(false);
        try {
            if (epmDocument != null) {
                Workable workable = null;
               
                if (epmDocument instanceof Iterated) {
                    Iterated it = (Iterated) epmDocument;
                    epmDocument = (EPMDocument) VersionControlHelper.service.getLatestIteration(it, false);
                }

                if (WorkInProgressHelper.isCheckedOut(epmDocument)) {
                    workable = WorkInProgressHelper.isWorkingCopy(epmDocument)
                        ? epmDocument
                        : WorkInProgressHelper.service.workingCopyOf(epmDocument);
                } else {
                    Folder myFolder = WorkInProgressHelper.service.getCheckoutFolder();
                    CheckoutLink link = WorkInProgressHelper.service.checkout(epmDocument, myFolder, "AutoCheckOut");
                    workable = link.getWorkingCopy();
                }

                return workable;
            }
        } catch (WTPropertyVetoException | WTException e) {
        } finally {
            SessionServerHelper.manager.setAccessEnforced(enforce);
        }
    } catch (RemoteException | InvocationTargetException e) {
    }
   
    return null;
}
 
for checkin i wrote this:

public static void doCheckIn(EPMDocument epmDocument) {
    try {
        if (!RemoteMethodServer.ServerFlag) {
            RemoteMethodServer.getDefault().invoke("doCheckIn", AddtoWSChekin.class.getName(), null,
                new Class[]{EPMDocument.class}, new Object[]{epmDocument});
            return;
        }
       
        boolean enforce = SessionServerHelper.manager.setAccessEnforced(false);
        try {
            if (epmDocument != null) {
                Workable workable = WorkInProgressHelper.isWorkingCopy(epmDocument)
                    ? epmDocument
                    : doCheckOut(epmDocument); // Get working copy if not already checked out

                WorkInProgressHelper.service.checkin(workable, "AutoCheckIn");
            }
        } catch (WTPropertyVetoException | WTException e) {
        } finally {
            SessionServerHelper.manager.setAccessEnforced(enforce);
        }
    } catch (RemoteException | InvocationTargetException e) {
    }
}
 
please help, I am able to do chekout and ceckin the CAD  but the WTPart is not removing from the structure.
10 REPLIES 10

Please Elaborate!

Hello @RaikarRaghu 

The functionality is not part of the checkin API helper. The functionality is part of some additional apis that are called during the pre-checking process from workgroup manager or from the commonspace Windchill.

 

If you do the check-in by own function, you have to do the structure build by own function or you have to call the build function that update the WTPart structure based on the CAD . 

Try this BuildHelper

WTHashSet buildEPM = new WTHashSet();
try
{
	EPMDocument epm = getCADDocumentOwnSearchFunction();
	buildEPM.addElement(epm);
	ConfigSpec configSpec = new EPMConfigSpecFilter(EPMDocConfigSpec.newEPMDocConfigSpec(), EPMFilters.NO_WORKING);
	BuildHelper.buildFromCAD(buildEPM, configSpec, false);
	System.out.println(String.format("Build WTP structure completed: %s ", epm.getNumber()));
	buildEPM.clear();
} catch (WTException e)
{
	System.out.println(String.format("The object can not be Synchonize: %s",buildEPM.toString()));
	e.printStackTrace();
	buildEPM.clear();
}

PetrH 

Hello ,

I added this code before the pre - checking process. it was throwing error:


Error : java.lang.ClassCastException: class wt.epm.util.EPMConfigSpecFilter cannot be cast to class com.ptc.windchill.uwgm.soap.uwgmsvc.ConfigSpec (wt.epm.util.EPMConfigSpecFilter and com.ptc.windchill.uwgm.soap.uwgmsvc.ConfigSpec are in unnamed module of loader 'app')

This is my import statements:

import com.ptc.windchill.uwgm.common.util.BuildHelper;

import com.ptc.windchill.uwgm.soap.uwgmsvc.ConfigSpec;

import wt.epm.util.EPMConfigSpecFilter;

This is the code i am using:

public static void doCheckIn(EPMDocument epmDocument){

try {

 

WTHashSet buildEPM = new WTHashSet();

try {

 

buildEPM.addElement(epmDocument);

ConfigSpec configSpec = (ConfigSpec) new EPMConfigSpecFilter(EPMDocConfigSpec.newEPMDocConfigSpec(), EPMFilters.NO_WORKING);

BuildHelper.buildFromCAD(buildEPM, (wt.vc.config.ConfigSpec) configSpec, false);

System.out.println(String.format("Build WTP structure completed: %s ", epmDocument.getNumber()));

buildEPM.clear();

}

catch (WTException e) {

System.out.println(String.format("The object can not be Synchonize: %s",buildEPM.toString()));

e.printStackTrace();

buildEPM.clear();

}

 

if (!RemoteMethodServer.ServerFlag) {

RemoteMethodServer.getDefault().invoke("doCheckIn", AddtoWSChekin.class.getName(), null, new Class[] { EPMDocument.class},

new Object[] { epmDocument});

} else {

boolean enforce = SessionServerHelper.manager.setAccessEnforced(false);

try{

if(epmDocument!=null){

Workable workable = null;

if(!WorkInProgressHelper.isWorkingCopy(epmDocument)){

workable = doCheckOut(epmDocument);

}else{

workable = epmDocument;

}

workable = WorkInProgressHelper.service.checkin(workable, "AutoCheckIn");

 

}

} catch(WTPropertyVetoException e){

} catch(WTException e){

}finally {

SessionServerHelper.manager.setAccessEnforced(enforce);

}

}

} catch (RemoteException e) {

} catch (InvocationTargetException e) {

}

}
Thanks
Raikar

Hi @RaikarRaghu 

It is simple. What does the error say?

It says that the Object type EPMConfigSpecFilter is not compatible with your ConfigSpec. Why?

Because EPMConfigSpecFilter is implementation of a ConfigSpec but from different package then you used. 

correct ConfigSpec is wt.vc.config.ConfigSpec not com.ptc.windchill.uwgm.soap.uwgmsvc.ConfigSpec.

 

If you use EPMConfigSpecFilter instead of ConfigSpec then it will also work.

 

EPMConfigSpecFilter configSpec = new EPMConfigSpecFilter(EPMDocConfigSpec.newEPMDocConfigSpec(), EPMFilters.NO_WORKING);

 

PetrH

Hello,

 

Thank you, I changed the code, now the code has no errors, but the Extrude from BOM functionality is not working. The Part structure is still remains same only.

 

Regards

Raikar

Hi @RaikarRaghu 

You should share a screen from a Compare to WTPart structure. from CAD to see why the build still build the WTPart in your structure.

I guess that you do something wrong for example the functionality to build the structure based on CAD has the filter and the filter is not defined a way you expected. So you have to find correct filter that is used to build the WTPart structure. . You have to play with it. 

PetrH

Hi,

When you do the action programmatically, are you checking if the value for the CAD attribute is set to "Yes" (CAD attribute that you have indicated in the preference "Part Structure Overridable Attribute").

 

Cheers

Hari

 

HelesicPetr
22-Sapphire I
(To:Hari_Vara)

@Hari_Vara good point

@RaikarRaghu Is the model attribute set as a designated in the model? Is the value really saved in a Windchill database? 

PetrH

Hello Peter,

It is a configuration in SolidWorks, and we create the attribute in the EPMDocumentUsageLink & use that value in the Preference "Part Structure Overridable Attribute"

 

thanks 

Raikar

Hi @RaikarRaghu 

The main point is if the value is really stored in the Windchill.

You haven't answered it yet. Show screenshot from a structure that the value is set to true. 

PetrH

Announcements

Top Tags