Message 1 of 2

Not applicable
09-06-2019
05:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
By using a ilogic rule I created a derived part from an assembly.
Ilogic rule used is mentioned below.
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) ' Save the part Dim partname As String=ThisDoc.PathAndFileName(False)& ".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
After creating derived part, I want to run the below program automatically in the derived part.
Dim oDoc As PartDocument oDoc = ThisApplication.ActiveDocument Dim oDef As PartComponentDefinition oDef = oDoc.ComponentDefinition Dim oTG As TransientGeometry oTG = ThisApplication.TransientGeometry Dim oAxis As WorkAxes Dim oWPlane As WorkPlane Dim FlatAngle As Double = Math.PI / 6 Dim NoSides As Integer = 12 Dim oSketch As PlanarSketch 'initialize counter Work1 = 1 ul Work2 = (NoSides / 2 ul) + Work1 oAxis= oDef.WorkAxes oWPlane = oDef.WorkPlanes.AddByLinePlaneAndAngle(oAxis("X Axis"), oDef.WorkPlanes("XZ Plane"), 0 deg) oWPlane.Name = CStr(Work1) & "-" & CStr(Work2) & " Plane" Dim oWPName As String = oWPlane.Name oWPlane.AutoResize = True oWPlane.Visible = False oSketch = oDef.Sketches.Add(oWPlane) oSketch.Name = "My_Sketch" & oWPName oSketch.ProjectedCuts.Add() oSketch.Visible = True InventorVb.DocumentUpdate() For Work1 = 2 To NoSides Work2 = (NoSides / 2 ul) + Work1 oWPlane = oDef.WorkPlanes.AddByLinePlaneAndAngle(oAxis("X Axis"), oDef.WorkPlanes(oWPName), FlatAngle/2) oWPlane.Name = CStr(Work1 + NoSides) & "-" & CStr(Work2 + NoSides) & " Plane" oWPName = oWPlane.Name oWPlane.AutoResize = True oWPlane.Visible = False oSketch = oDef.Sketches.Add(oWPlane) oSketch.Name = "My_Sketch" & oWPName oSketch.ProjectedCuts.Add() oSketch.Visible = True Next
Solved! Go to Solution.