- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have an iLogic rule in an assembly file which shrinkwraps the model when the document is closed.
But I would also like to push some of the assemblies' iproperties to the newly created shrinkwrapped part file.
I have tried the following code but I get the error:
iProperties:The document named "C:\Inventor Projects\WALKWAYS\WW - WALKWAY ASSEMBLY (SHRINKWRAPPED).ipt" was not found.
even though the file is there in the correct location.
Can anyone see where I'm going wrong?
Dim docFName As String Dim oDoc As Inventor.Document = docFName docFName = ThisDoc.PathAndFileName(False)& " (SHRINKWRAPPED).ipt" iProperties.Value(docFName, "Project", "Description") = iProperties.Value("Project", "Description") iProperties.Value(docFName, "Custom", "DRAWING No.") = iProperties.Value("Custom", "DRAWING No.")
The full iLogic code for the shrinkwrap that I'm trying to use above snippet in is as follows:
Sub Main() 'CHECK ACTIVE DOCUMENT IS THE SAME DOCUMENT THAT CONTAINS THIS iLOGIC RULE. 'THIS CHECK IS TO PREVENT THE RULE FROM ATTEMPTING TO RUN WHEN CLOSING THE DRAWING SHEET. Dim activeDoc As Document = ThisApplication.ActiveDocument If Not activeDoc Is ThisDoc.Document Then Exit Sub Else Question = MessageBox.Show("Do you wish to shrinkwrap the Walkway Assembly now for use in the General Arrangement?", "Walkway Assembly",MessageBoxButtons.YesNo) If Question = vbYes Then Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Default").Activate Try Dim g_App As Inventor.InventorServer = ThisApplication Dim AssDoc as Inventor.AssemblyDocument= ThisDoc.Document 'CREATE A NEW PART DOCUMENT THAT WILL BE THE SHRINKWRAP SUBSTITUTE Dim oPartDoc As PartDocument oPartDoc = g_App.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , True) Dim oPartDef As PartComponentDefinition oPartDef = oPartDoc.ComponentDefinition Dim oDerivedAssemblyDef As DerivedAssemblyDefinition oDerivedAssemblyDef = oPartDef.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(AssDoc.FullDocumentName) 'SET VARIOUS SHRINKWRAP RELATED OPTIONS oDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll oDerivedAssemblyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll oDerivedAssemblyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll Call oDerivedAssemblyDef.SetHolePatchingOptions(DerivedHolePatchEnum.kDerivedPatchNone) Call oDerivedAssemblyDef.SetRemoveByVisibilityOptions(DerivedGeometryRemovalEnum.kDerivedRemoveNone) Dim oDerivedAss As DerivedAssemblyComponent oDerivedAss = oPartDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef) Call oDerivedAss.BreakLinkToFile() 'SAVE THE PART Dim partname As String=ThisDoc.PathAndFileName(False)& " (SHRINKWRAPPED).ipt" ThisApplication.ActiveView.Fit ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute Call oPartDoc.SaveAs(partname , False) Catch ex As Exception ErrorMessage = "Error creating ipt file." End Try 'Try Dim docFName As String Dim oDoc As Inventor.Document = docFName docFName = ThisDoc.PathAndFileName(False)& " (SHRINKWRAPPED).ipt" iProperties.Value(docFName, "Project", "Description") = iProperties.Value("Project", "Description") iProperties.Value(docFName, "Custom", "DRAWING No.") = iProperties.Value("Custom", "DRAWING No.") 'Catch 'End Try oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item("Default").Activate Else 'CLOSE MESSAGE BOX AND DO NOTHING End If End If End Sub
Solved! Go to Solution.
Link copied