- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
Im currently almost finished with an automated dimension program for drawings based on Work-planes in the model. It does work, however I cant seem to access work-planes from inside a sub Component Occurrence within the main assembly. Here's What I have:
Public shared function CreateLinearDimensionV2(ViewName as string, WorkPlane1 As String, WorkPlane2 As String, Optional SubOccurenceName As string = Nothing)
InvApp = Marshal.GetActiveObject("Inventor.Application") Dim oDoc As Inventor.DrawingDocument Dim DrawingView As Inventor.DrawingView Dim oSheet As Sheet Dim DimOffsetHeight As Decimal = 1 Try oDoc = InvApp.ActiveDocument oSheet = oDoc.ActiveSheet DrawingView = DrawingViewScan(oSheet, ViewName) Catch ex As Exception Console.WriteLine("Drawing Document not open.") Return False End Try ' Dim oSubDoc As AssemblyDocument oSubDoc = DrawingView.ReferencedDocumentDescriptor.ReferencedDocument Dim oOcc1 As Inventor.WorkPlane Dim oOcc2 As Inventor.WorkPlane Dim Line1 As Centerline Dim Line2 As Centerline If (SubOccurenceName IsNot Nothing) Then 'If user has given a sub name then try and find the occurence and get the work planes Dim oPartDoc1 As ComponentOccurrence Try oPartDoc1 = oSubDoc.ComponentDefinition.Occurrences.ItemByName(SubOccurenceName) Catch Console.WriteLine("Unable to find SubOccurence.") Return False End Try oOcc1 = oPartDoc1.Definition.WorkPlanes.Item(WorkPlane1) oOcc2 = oPartDoc1.Definition.WorkPlanes.Item(WorkPlane2) Else 'If no sub part is specified just get the planes in the main assembly oOcc1 = oSubDoc.ComponentDefinition.WorkPlanes.Item(WorkPlane1) oOcc2 = oSubDoc.ComponentDefinition.WorkPlanes.Item(WorkPlane2) End If
Line1 = oSheet.Centerlines.AddByWorkFeature(oOcc1, DrawingView) 'Program breaks when SubOccurenceName is provided Line2 = oSheet.Centerlines.AddByWorkFeature(oOcc2, DrawingView)
. . .
So here's the break down, when I give 'SubOccurenceName' a sub assembly it then finds the work-planes I provided in that occurrence, then program breaks at the creation of the center lines. (Gives a useless error... as always) It definitely finds the work-planes It just has to be something with the Center-lines. It works great when the planes are in the context of the main assembly (Where 'SubOccurenceName' is nothing)!
Im thinking its probably something simple I just cant figure it out!
Any Help would be appreciated, Thanks!
Solved! Go to Solution.