Code:
Sub Main()
iLogicVb.MemberEditScope = MemberEditScopeEnum.kEditActiveMember
' Set a reference to the active assembly document
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oDef As AssemblyComponentDefinition
oDef = oDoc.ComponentDefinition
' Create a new part document that will be the shrinkwrap substitute
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, , False)
Dim oPartDef As PartComponentDefinition
oPartDef = oPartDoc.ComponentDefinition
Dim oDerivedAssemblyDef As DerivedAssemblyDefinition
oDerivedAssemblyDef = oPartDef.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(oDoc.FullDocumentName)
' Set various shrinkwrap related options
oDerivedAssemblyDef.DeriveStyle = 80642 '"kDeriveAsSingleBodyNoSeams"
oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = kDerivedIncludeAll
oDerivedAssemblyDef.IncludeAllTopLevelSketches = kDerivedIncludeAll
oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelParameters = kDerivedExcludeAll
oDerivedAssemblyDef.ReducedMemoryMode = True
Call oDerivedAssemblyDef.SetHolePatchingOptions(kDerivedPatchNone)
Call oDerivedAssemblyDef.SetRemoveByVisibilityOptions(kDerivedRemovePartsAndFaces, 1)
'
'Zeile 32
' Create the shrinkwrap component
Dim oDerivedAssembly As DerivedAssemblyComponent
oDerivedAssembly = oPartDef.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)
'Zeile 36
' Save the part
'Dim strSubstituteFileName As String
'strSubstituteFileName = Left$(oDoc.FullFileName, Len(oDoc.FullFileName) - 4)
'strSubstituteFileName = strSubstituteFileName & "_ShrinkwrapSubstitute.ipt"
'***
Dim oDate As String = DateTime.Now.ToString("yyyy.MM.dd")
Dim AssDoc As Inventor.AssemblyDocument = TryCast(ThisDoc.Document, AssemblyDocument)
Dim Directory As String = System.IO.Path.GetDirectoryName(AssDoc.FullFileName)
Dim FolderName As String = "abgeleitet & vereinfacht"
Directory = System.IO.Path.Combine(Directory, FolderName)
If Not System.IO.Directory.Exists(Directory)
System.IO.Directory.CreateDirectory(Directory)
End If
Dim strSubstituteFileName As String = "vb_" & System.IO.Path.Combine(Directory, System.IO.Path.GetFileNameWithoutExtension(AssDoc.FullFileName)& " Rev." & iProperties.Value("Project", "Revision Number") &" Stand " & oDate & ".ipt")
'***
ThisApplication.SilentOperation = True
Call oPartDoc.SaveAs(strSubstituteFileName, False)
ThisApplication.SilentOperation = False
' Create a substitute level of detail using the shrinkwrap part.
Dim oSubstituteMS As ModelState
oSubstituteMS = oDef.ModelStates.AddSubstitute(strSubstituteFileName)
' Release reference of the invisibly opened part document.
oPartDoc.ReleaseReference
End Sub