Is there any way to generate sheet of part related with assembly automatically

Is there any way to generate sheet of part related with assembly automatically

ssiem12
Contributor Contributor
1,052 Views
5 Replies
Message 1 of 6

Is there any way to generate sheet of part related with assembly automatically

ssiem12
Contributor
Contributor

hello

what i want is if i have an assembly(1) and it hase 2 assembly(1-1,1-2) and 4 parts(1-3,1-4,1-5,1-6) and (1-1,1-2) has 2 parts(1-1-1,1-1-2/1-2-1, 1-2-2) respectively

i want ilogic generate 10 sheets(1-1,1-1-1,1-1-2, 1-2, 1-2-1, 1-2-2, 1-3, 1-4, 1-5, 1-6) when i run ilogic

i don't mind if view or scale is proper

i'm drafting 700 sheets now it just half

I forget what number i should draft

could you help me please?

0 Likes
1,053 Views
5 Replies
Replies (5)
Message 2 of 6

A.Acheson
Mentor
Mentor

Hi @ssiem12  are you wanting to rename the drawing sheets? If so can you attach a screenshot of where the name is to be taken from? Can you attach any code you have all ready worked on?

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 6

JelteDeJong
Mentor
Mentor

give this a shot:

Sub Main()
    Dim doc As AssemblyDocument = ThisDoc.Document
    Dim def As AssemblyComponentDefinition = doc.ComponentDefinition

    Dim dDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject)
    Dim sheet As Sheet = dDoc.ActiveSheet

    FillSheet(sheet, doc)

    For Each refDoc As Document In doc.AllReferencedDocuments
        Dim newSHeet = dDoc.Sheets.Add()
        FillSheet(newSHeet, refDoc)
    Next
End Sub

Private Sub FillSheet(sheet As Sheet, doc As Document)
    sheet.Name = doc.DisplayName
    Dim sheetW4 = sheet.Width / 4
    Dim sheetH4 = sheet.Height / 4

    Dim position As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4, sheetH4)
    Dim baseView As DrawingView = sheet.DrawingViews.AddBaseView(doc, position, 1, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
    Dim scale = CalculateScale(baseView)

    position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4 * 3, sheetH4)
    Dim view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
    scale = Math.Min(scale, CalculateScale(view))

    position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4, sheetH4 * 3)
    view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
    scale = Math.Min(scale, CalculateScale(view))

    position = ThisApplication.TransientGeometry.CreatePoint2d(sheetW4 * 3, sheetH4 * 3)
    view = sheet.DrawingViews.AddProjectedView(baseView, position, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
    scale = Math.Min(scale, CalculateScale(view))

    baseView.Scale = scale
End Sub

Private Function CalculateScale(view As DrawingView) As Double
    Dim scaleX = view.Parent.Width / view.Width / 2
    Dim scaleY = view.Parent.Height / view.Height / 2
    Return Math.Min(scaleX, scaleY)
End Function

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 4 of 6

AlwaysFriend
Observer
Observer

Yes, it is possible to generate a drawing sheet for each part and sub-assembly in an assembly using iLogic in Autodesk Inventor. Here's an example code that you can modify for your specific assembly structure:

 

 

' Get the active assembly document
Dim asmDoc As AssemblyDocument = ThisApplication.ActiveDocument

' Loop through all components in the assembly
For Each comp As ComponentOccurrence In asmDoc.ComponentDefinition.Occurrences

    ' Check if the component is a part or sub-assembly
    If TypeOf comp.Definition Is PartComponentDefinition OrElse TypeOf comp.Definition Is SubassemblyComponentDefinition Then

        ' Get the document for the component
        Dim doc As Document = comp.Definition.Document

        ' Check if the component has a drawing view
        If doc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then

            ' Get the drawing view
            Dim dwgDoc As DrawingDocument = doc
            Dim view As DrawingView = dwgDoc.ActiveSheet.DrawingViews.AddBaseView(comp, comp.Transformation)

            ' Set the view scale
            view.Scale = 1

            ' Set the view style
            view.Style = ThisApplication.ActiveDocument.StylesManager.ActiveStyle

            ' Set the view position
            view.Position = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)

            ' Set the view orientation
            view.ViewOrientationType = DrawingViewOrientationTypeEnum.kNormalToViewPlane
            view.ViewDirection = ThisApplication.TransientGeometry.CreateVector(0, 0, 1)
        End If
    End If
Next

This code will loop through all components in the active assembly document and check if they are parts or sub-assemblies. For each part or sub-assembly, it will check if there is a drawing document for that component. If there is, it will create a new drawing view for that component and set its scale, style, position, and orientation.

To customize this code for your specific assembly structure, you will need to modify the component selection criteria and the sheet naming convention. For example, you could use the component names to generate sheet names like "1-1-1", "1-1-2", "1-2-1", etc.

0 Likes
Message 5 of 6

Cadkunde.nl
Collaborator
Collaborator

Watning, all his posts are generated by chatgpt

Message 6 of 6

ssiem12
Contributor
Contributor

Thank you for you advice and sorry for my late reply

I've run your code and there are 2 issues

 

1. there is incorrect parameter on 26 row

I guess it caused by my Inventor is korean language version

I can handle it if it's caused by this reason

 

2. It start from AssemblyDocument

I want to generate sheet on document where I'm writing so generated sheet will follow style of sheet and i can apply it on design change issue.

I'm not good at ilogic as much as you but how about I draft assembly and browse first then i run ilogic.

codes start to gather information from assembly i browse on sheet then it generate sheet of gathered information.

 

Thank you for your kindness

0 Likes