
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi guys, I'm trying to automate making a shrinkwrap of some assemblies that I made that are also configurable using iLogic. I want to be able to make a shrinkwrap of the Assembly without having a substitute representation and also break the link with the Assembly so we can make a 3D block Library.
I tried using the sample code in the Programming Help but I keep getting an error. I made a simple counting function to see where I'm going wrong and I've narrowed it down to after count #6.
I'm using a 64bit Windows 7 computer with the Factory Design Suite on it. Factor Design Suite is mostly just an add-on to Inventor 2011 so I'm not sure if that is causing the error.
I have some experience with programming but I haven't had any formal VBA classes so I've been mostly just guessing and running it to try to fix the problem but I've run into a wall. Can someone tell me what I'm doing wrong?
Here is my code and the error that it gives me when I try to run it:
Code:
Sub CreateShrinkwrap(ShrinkwrapFolder As String)
Parameter("COUNT") = 0
' Find the part File Path and Name
PART_NUMBER = iProperties.Value("Project", "Part Number")
ShrinkwrapFilePath = String.Concat("L:\Mechanical\Inventor\COMPONENT DETAILS\", ShrinkwrapFolder, "\")
ShrinkwrapFileName = String.Concat(ShrinkwrapFilePath, PART_NUMBER, ".ipt")
Call SET_COUNT() 'COUNT = 1
' Set a reference to the active assembly document
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Call SET_COUNT() 'COUNT = 2
Dim oDef As AssemblyComponentDefinition
oDef = oDoc.ComponentDefinition
Call SET_COUNT() 'COUNT = 3
'Set the Template file name:
TemplateFileName = "\\fs3\Depts\Product_Engineering\Inventor_File_Repository\INVENTOR 2011 FILES\Templates\Shrinkwrap.ipt"
' Create a new part document that will be the shrinkwrap substitute
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, TemplateFileName, False)
Call SET_COUNT() 'COUNT = 4
Dim oPartDef As PartComponentDefinition
oPartDef = oPartDoc.ComponentDefinition
Call SET_COUNT() 'COUNT = 5
Dim oDerivedAssemblyDef As DerivedAssemblyDefinition
oDerivedAssemblyDef = oPartDef.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(oDoc.FullDocumentName)
Call SET_COUNT() 'COUNT = 6
' Set various shrinkwrap related options
oDerivedAssemblyDef.DeriveStyle = kDeriveAsSingleBodyNoSeams
oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = kDerivedIncludeAll
oDerivedAssemblyDef.IncludeAllTopLevelSketches = kDerivedIncludeAll
oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelParameters = kDerivedExcludeAll
oDerivedAssemblyDef.ReducedMemoryMode = True
Call oDerivedAssemblyDef.SetHolePatchingOptions(kDerivedPatchAll)
Call oDerivedAssemblyDef.SetRemoveByVisibilityOptions(kDerivedRemovePartsAndFaces, 25)
Call SET_COUNT() 'COUNT = 7
' Create the shrinkwrap component
Dim oDerivedAssembly As DerivedAssemblyComponent
oDerivedAssembly = oPartDef.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)
oDerivedAssembly.BreakLinkToFile
Call SET_COUNT() 'COUNT = 8
ThisApplication.SilentOperation = True
oPartDoc.SaveAs(ShrinkwrapFileName, False)
ThisApplication.SilentOperation = False
Call SET_COUNT() 'COUNT = 9
' Release reference of the invisibly opened part document.
oPartDoc.ReleaseReference
Call SET_COUNT() 'COUNT = 10
End Sub
Error Message:
Error in rule: MAKE SHRINKWRAP, in document: 1354-8000.iam
Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
More Info:
System.Runtime.InteropServices.COMException (0x80004005): Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.DerivedAssemblyDefinition.set_IncludeAllTopLevelWorkFeatures(DerivedComponentOptionEnum )
at LmiRuleScript.CreateShrinkwrap(String ShrinkwrapFolder)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at p.b(String A_0)
Solved! Go to Solution.