- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all, my aim to place base view of all parts of assembly, I've tried below code and it's working okay to add parts base new, now i need to find out which parts are repetitively used in assembly and not need to add base view of same parts. And I also need to adjust scale and postion of view based on Sheet size.
Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Dim oDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition Dim oOcc As ComponentOccurrence Dim oTPath As String = "C:\Users\Public\Documents\Autodesk\Inventor 2023\Templates\en-US" Dim oTName As String = "Standard.idw" Dim oTFullFileName As String = System.IO.Path.Combine(oTPath, oTName) Dim oDDoc As DrawingDocument = Nothing If System.IO.File.Exists(oTFullFileName) Then oDDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, oTFullFileName, True) Else MsgBox("Template Drawing could not be found!", vbCritical, "") Exit Sub End If Dim oTG As TransientGeometry = ThisApplication.TransientGeometry Dim oViews As DrawingViews = oDDoc.ActiveSheet.DrawingViews Dim oFullScale As Double = 1/5 Dim oOriginPoint As Point2d = oTG.CreatePoint2d(0, 0) For Each oOcc In oDef.Occurrences Dim oOccDoc As Document = oOcc.Definition.Document Dim oBaseView As DrawingView = oViews.AddBaseView(oOccDoc, oOriginPoint, oFullScale, _ kBottomViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle) Next
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @vdcrocks7
For this you can use referenced documents instead of occurrences. Referenced document is the document all of the same occurrence reference so their is only one. See article here on working with assemblies and look for paragraph Reference Documents.
Sub Main
ShowReferences()
End Sub
Public Sub ShowReferences()
' Get the active assembly.
Dim oAsmDoc As AssemblyDocument
oAsmDoc = ThisApplication.ActiveDocument
' Get all of the referenced documents.
Dim oRefDocs As DocumentsEnumerator
oRefDocs = oAsmDoc.AllReferencedDocuments
' Iterate through the list of documents.
Dim oRefDoc As Document
For Each oRefDoc In oRefDocs
Logger.Info(oRefDoc.DisplayName)
Next
End Sub
Or if this helped you, please, click (like)
Regards
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
@A.Acheson Thank you for Solution, yes, I've updated my code to References document, and now it's only placed base view of unique parts only, could you please help me more on that as I described earlier, I'm interested to place view, so it'll not overlap as well control scale based on Sheet size.
Please find my updated code below :
Dim oAsmDoc As AssemblyDocument oAsmDoc = ThisApplication.ActiveDocument Dim oDef As AssemblyComponentDefinition = oAsmDoc.ComponentDefinition Dim oOcc As ComponentOccurrence Dim oTPath As String = "C:\Users\Public\Documents\Autodesk\Inventor 2023\Templates\en-US" Dim oTName As String = "Standard.idw" Dim oTFullFileName As String = System.IO.Path.Combine(oTPath, oTName) Dim oDDoc As DrawingDocument = Nothing If System.IO.File.Exists(oTFullFileName) Then oDDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, oTFullFileName, True) Else MsgBox("Template Drawing could not be found!", vbCritical, "") Exit Sub End If Dim oTG As TransientGeometry = ThisApplication.TransientGeometry Dim oViews As DrawingViews = oDDoc.ActiveSheet.DrawingViews Dim oFullScale As Double = 1/5 Dim oOriginPoint As Point2d = oTG.CreatePoint2d(0, 0) Dim oRefDocs As DocumentsEnumerator oRefDocs = oAsmDoc.AllReferencedDocuments ' Iterate through the list of documents. Dim oRefDoc As Document For Each oRefDoc In oRefDocs Dim oBaseView As DrawingView = oViews.AddBaseView(oRefDoc, oOriginPoint, oFullScale, _ kBottomViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle) Next
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi @vdcrocks7
Those two topics are very difficult so you will need to do your research on them. Depending on your view layout complexity the view scale can be achieved by just checking the view height x width of each view and adjust the scale untill it comes inside the sheet rangebox. Regarding overlapping really the easiest method is to check height x width of each view against its location and determine if they are overlapping. I have seen a few post getting overlapping drawing curves but that definitely isn't for the beginner.
A quick internet search using kewords
"ilogic autoscale drawing view"
Or if this helped you, please, click (like)
Regards
Alan