Simplified Part from Assembly

Simplified Part from Assembly

mowag
Enthusiast Enthusiast
245 Views
2 Replies
Message 1 of 3

Simplified Part from Assembly

mowag
Enthusiast
Enthusiast

Hi,

i'm trying to create a simplified part of a weldassembly ( with all the machinings supressed).

Most of the time it works, but sometimes i get an error Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)).

Where do i have to start looking ?

// Create a new part document that will be the shrinkwrap substitute  AFGEWERKT
PartDocument oPartDoc = (PartDocument)_inventordataService.invApp.Documents.Add(DocumentTypeEnum.kPartDocumentObject, "", false);

PartComponentDefinition oPartDef = oPartDoc.ComponentDefinition;

DerivedAssemblyDefinition oDerivedAssemblyDef = oPartDef.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(AssDoc.FullDocumentName);

// Set various shrinkwrap related options
oDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyNoSeams;
oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedIncludeAll;
oDerivedAssemblyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedIncludeAll;
oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll;
oDerivedAssemblyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll;
oDerivedAssemblyDef.ReducedMemoryMode = true;

//oDerivedAssemblyDef.SetHolePatchingOptions(DerivedHolePatchEnum.kDerivedPatchAll);
oDerivedAssemblyDef.SetRemoveByVisibilityOptions(DerivedGeometryRemovalEnum.kDerivedRemovePartsAndFaces, 25);

// Create the shrinkwrap component
DerivedAssemblyComponent oDerivedAssembly = oPartDef.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef);

 

Screenshot_SimplifiedPart.png

Kind Regards

 

Johan

0 Likes
246 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor

Is the assembly full document name supplied a valid path? If you tried to open the assembly with that name would it work? Perhaps place a try catch statement around any line you think may be at fault. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 3

mowag
Enthusiast
Enthusiast

Hi Allen,

 

Yes the path to the assembly is valid. I'm sure about that !!

I've wrote an app that starts wit an open assy in inventor and loops over all the occurences of the assy (also subassy's).

When i run the app with the assy open that contains the weld assy as a subassy then i have no problem !

When i start the app with an assy open higher in the hierachy ( weld assy is sub,sub,subassy) then i get the error ?

 

Here are the weld assy's just under the top assy and in that case it's working ! Strange, isn't it ?

 

Screenshot_SimplifiedPart1.png

 

0 Likes