Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Show only
|
Search instead for
Did you mean:
This page has been translated for your convenience with an automatic translation service. This is not an official translation and may contain errors and inaccurate translations. Autodesk does not warrant, either expressly or implied, the accuracy, reliability or completeness of the information translated by the machine translation service and will not be liable for damages or losses caused by the trust placed in the translation service.Translate
I came up with a solution to this problem. I tried to attach the whole iRule as a file here, but there is no option, so I copied whole code down below. I hope you will find it useful!
'######################'iRule "IDW_SetFirstDrawingView" created by Rene Repina'https://www.linkedin.com/in/renerepina/'https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5053305'######################'### IMPORTANT INFO ###'Mouse has to be positioned on the drawing, otherwise PASTE does not work and it will cause an error!'COPY-PASTE functions are used, because commands such as "CopyTo" (and others) break the aligning to the base views.'All connections (alignings) are preserved.'Letters of the sections view, details, ... are changed to the next ones of the sequence after the set (due to copy and delete).'######################'Run only on drawingsIfThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObjectThenMessageBox.Show("Rule works only on drawings!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ExitSubEndIf'ObjectsDimoDrawDocAsDrawingDocument = ThisApplication.ActiveDocumentDimoDrawingViewAsDrawingViewDimmainSheetAsSheet = oDrawDoc.ActiveSheetDimtempSheetAsSheetDimfirstDrawingViewAsDrawingViewDimviewsForDeletionAsNewList(OfDrawingView)
DimdrawingViewsCountBeforeAsInteger = mainSheet.DrawingViews.CountDimdrawingViewsCountAfterAsInteger = 0
DimoThreadAsSystem.Threading.Thread = System.Threading.Thread.CurrentThreadDimoThreadTimeAsInteger = 100 'ms 'Needed to prevent errors (time for commands to process)'Check if user selected a drawing viewTryfirstDrawingView = oDrawDoc.SelectSet(1)
CatchMessageBox.Show("Select the main view and run again!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ExitSubEndTry'Check if selected drawing view is NOT a parent view (parent view should be selected)IffirstDrawingView.ParentViewIsNotNothingThenMessageBox.Show("Selected view is NOT a parent view!" & vbLf & vbLf & "Select a parent view and run again!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ExitSubEndIf'Only 1 drawing view should be selectedIfoDrawDoc.SelectSet.Count <> 1 ThenMessageBox.Show("Multiple drawing views are selected!" & vbLf & vbLf & "Select only ONE drawing view and run again!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning)
ExitSubEndIf'Mouse cursor MUST be on the drawing, otherwise it will cause an error due to PASTE function not working outside drawing bordersMessageBox.Show("The mouse cursor MUST be on the drawing, otherwise it will cause an error!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)
'Clear select set (to deselect user selected view)oDrawDoc.SelectSet.Clear()
'Select all views except the main (selected) onesForEachoDrawingViewInmainSheet.DrawingViewsIfoDrawingViewIsNotfirstDrawingViewAndAlsooDrawingView.ParentViewIsNotfirstDrawingViewThenoDrawDoc.SelectSet.Select(oDrawingView)
viewsForDeletion.Add(oDrawingView)
EndIfNext'Undo transaction to reverse changes in case of an error (or user undo command)DimundoAsTransaction = ThisApplication.TransactionManager.StartTransaction(oDrawDoc, "Set First Drawing View")
'undo.End 'Needed at the end of where you want to endThisApplication.CommandManager.ControlDefinitions.Item("AppCopyCmd").Execute() 'Copy views'oThread.Join(oThreadTime) 'OPTIONAL IF NEEDEDoDrawDoc.Sheets.Add() 'Add temp sheettempSheet = oDrawDoc.ActiveSheet'Save temp sheet for the referenceoThread.Join(oThreadTime) 'Needed to properly switch to the sheetThisApplication.CommandManager.ControlDefinitions.Item("AppPasteCmd").Execute() 'Paste viewoThread.Join(oThreadTime) 'Needed to give time to paste'Delete all views on main sheet except main (selected) viewsForEachoDrawingViewInviewsForDeletion'Try-Catch is needed in case depended views get deleted before for loop can delete themTryoDrawingView.Delete()
Catch'View is already deleted, go to the next oneEndtryNexttempSheet.Activate() 'Activate temporary sheetoThread.Join(oThreadTime) 'Needed to properly switch to the sheet'Select all views on temporary sheetForEachoDrawingViewIntempSheet.DrawingViewsoDrawDoc.SelectSet.Select(oDrawingView)
NextThisApplication.CommandManager.ControlDefinitions.Item("AppCopyCmd").Execute() 'Copy views'oThread.Join(oThreadTime) 'OPTIONAL IF NEEDEDmainSheet.Activate() 'Go to main sheetoThread.Join(oThreadTime) 'Needed to properly switch to the sheetThisApplication.CommandManager.ControlDefinitions.Item("AppPasteCmd").Execute() 'Paste viewsoThread.Join(oThreadTime) 'Needed to give time to pastetempSheet.Delete(False) 'Delete temporary sheet'oThread.Join(oThreadTime) 'OPTIONAL IF NEEDED'Get the final count number of the views to compare it to start count number of the viewsdrawingViewsCountAfter = mainSheet.DrawingViews.Countundo.End'End undo transactionIfdrawingViewsCountBefore <> drawingViewsCountAfterThenMessageBox.Show("Something went wrong!" & vbLf & "Number of views before the set is not the same to the number of views after!" & vbLf & vbLf &
"State will be reversed. Try again!" & vbLf & "(Mouse cursor MUST be on the drawing!)", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
'Undo the current transaction (to reverse changes)ThisApplication.TransactionManager.UndoTransaction()
ExitSubEndIf
This solution doesn't work if you have section views and sketches on the views as the sketches don't appear to be able to be copied with the base view. I don't understand why this has been ignored for so long, other software allows the reference view for the sheet properties to be selected or overridden. Access to the sheet properties (similar to iproperties for other objects) would be extremely helpful for many circumstances, and save a lot of time.
This idea has been implemented within Autodesk Inventor 2023. Please review the Inventor 2023 What's New article here. For more information regarding how you may leverage the feature, please review this page. Special thanks to everyone who cast a vote for it.