Jump to content

Shrinkwrap using iLogic.


GatorDanner

Recommended Posts

Hi everyone, 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_Rep​ository\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.DerivedAssemblyCompon​ents.CreateDefinition(oDoc.FullDocumentName)

 

Call SET_COUNT() 'COUNT = 6

 

' Set various shrinkwrap related options

oDerivedAssemblyDef.DeriveStyle = kDeriveAsSingleBodyNoSeams

oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = kDerivedIncludeAll

oDerivedAssemblyDef.IncludeAllTopLevelSketches = kDerivedIncludeAll

oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinit​ions = kDerivedExcludeAll

oDerivedAssemblyDef.IncludeAllTopLevelParameters = kDerivedExcludeAll

oDerivedAssemblyDef.ReducedMemoryMode = True

 

Call oDerivedAssemblyDef.SetHolePatchingOptions(kDerive​dPatchAll)

Call oDerivedAssemblyDef.SetRemoveByVisibilityOptions(k​DerivedRemovePartsAndFaces, 25)

 

Call SET_COUNT() 'COUNT = 7

 

' Create the shrinkwrap component

Dim oDerivedAssembly As DerivedAssemblyComponent

oDerivedAssembly = oPartDef.ReferenceComponents.DerivedAssemblyCompon​ents.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(Strin​g memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)

at Inventor.DerivedAssemblyDefinition.set_IncludeAllT​opLevelWorkFeatures(DerivedComponentOptionEnum )

at LmiRuleScript.CreateShrinkwrap(String ShrinkwrapFolder)

at LmiRuleScript.Main()

at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly​(Assembly assem)

at p.b(String A_0)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...