Skip to main content
12-Amethyst
December 23, 2024
Question

Extrude from BOM functionality is not working through customization

  • December 23, 2024
  • 3 replies
  • 1835 views

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.

3 replies

12-Amethyst
December 26, 2024

Please Elaborate!

HelesicPetr
22-Sapphire II
22-Sapphire II
January 2, 2025

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 

12-Amethyst
January 3, 2025

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

HelesicPetr
22-Sapphire II
22-Sapphire II
January 3, 2025

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

16-Pearl
January 6, 2025

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 II
22-Sapphire II
January 6, 2025

@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

12-Amethyst
January 7, 2025

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