Anonymous
334 Views, 0 Replies
11-24-2016
01:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-24-2016
01:53 AM
Ilogic Save derived file
Hi,
I'm trying to create an ilogic that creates a derived part and saves that derived part in a spesific location in my project file. I will not claim that this is something that I have created my self, it is more of a "copy/paste"-creation.
SyntaxEditor Code Snippet
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() FEMDirectory = ThisDoc.Path()&"\FEM" oFileName = ThisDoc.FileName(False) & ".ipt" ' Save the part Dim partname As String=ThisDoc.PathAndFileName(False)& ".ipt" ThisApplication.ActiveView.Fit ThisApplication.CommandManager.ControlDefinitions.Item("AppIsometricViewCmd").Execute Call oPartDoc.SaveAs(FEMDirectory & "\" & "FEM_" & oFileName, False) Catch ex As Exception ErrorMessage = "Error creating ipt file." End Try
My problem is that this ilogic saves the derived part in a new folder in the assembly folder e.g: C:\...\project\Assembly\FEM. When I want it to save to an already existing folder one leve up: C:\...\project\FEM. I think the problem has to be that "ThisDoc.Path" is referering to the assembly folder. I have also tried with "Thisdoc.workspacepath", but this creates an FEM folder on the c-drive, C:\FEM, where it save the derived file. Any help out there?