cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

change "main view" in drawings

change "main view" in drawings

i would be able to change the main view in drawings which is used for properties to sync into the title block

26 Comments
ReneRepina
Collaborator

Hello everybody!

 

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 drawings
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MessageBox.Show("Rule works only on drawings!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning)
	Exit Sub
End If

'Objects
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oDrawingView As DrawingView
Dim mainSheet As Sheet = oDrawDoc.ActiveSheet
Dim tempSheet As Sheet
Dim firstDrawingView As DrawingView
Dim viewsForDeletion As New List(Of DrawingView)
Dim drawingViewsCountBefore As Integer = mainSheet.DrawingViews.Count
Dim drawingViewsCountAfter As Integer = 0
Dim oThread As System.Threading.Thread = System.Threading.Thread.CurrentThread
Dim oThreadTime As Integer = 100 'ms 'Needed to prevent errors (time for commands to process)

'Check if user selected a drawing view
Try
	firstDrawingView = oDrawDoc.SelectSet(1)
Catch
	MessageBox.Show("Select the main view and run again!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning)
	Exit Sub
End Try

'Check if selected drawing view is NOT a parent view (parent view should be selected)
If firstDrawingView.ParentView IsNot Nothing Then
	MessageBox.Show("Selected view is NOT a parent view!" & vbLf & vbLf & "Select a parent view and run again!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning)
	Exit Sub
End If

'Only 1 drawing view should be selected
If oDrawDoc.SelectSet.Count <> 1 Then
	MessageBox.Show("Multiple drawing views are selected!" & vbLf & vbLf & "Select only ONE drawing view and run again!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning)
	Exit Sub
End If

'Mouse cursor MUST be on the drawing, otherwise it will cause an error due to PASTE function not working outside drawing borders
MessageBox.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) ones
For Each oDrawingView In mainSheet.DrawingViews

	If oDrawingView IsNot firstDrawingView AndAlso 
		oDrawingView.ParentView IsNot firstDrawingView Then
		
		oDrawDoc.SelectSet.Select(oDrawingView)
		viewsForDeletion.Add(oDrawingView)

	End If

Next

'Undo transaction to reverse changes in case of an error (or user undo command)
Dim undo As Transaction = ThisApplication.TransactionManager.StartTransaction(oDrawDoc, "Set First Drawing View")
'undo.End 'Needed at the end of where you want to end


ThisApplication.CommandManager.ControlDefinitions.Item("AppCopyCmd").Execute() 'Copy views
'oThread.Join(oThreadTime) 'OPTIONAL IF NEEDED

oDrawDoc.Sheets.Add() 'Add temp sheet
tempSheet = oDrawDoc.ActiveSheet 'Save temp sheet for the reference
oThread.Join(oThreadTime) 'Needed to properly switch to the sheet

ThisApplication.CommandManager.ControlDefinitions.Item("AppPasteCmd").Execute() 'Paste view
oThread.Join(oThreadTime) 'Needed to give time to paste

'Delete all views on main sheet except main (selected) views
For Each oDrawingView In viewsForDeletion
	
	'Try-Catch is needed in case depended views get deleted before for loop can delete them
	Try
		oDrawingView.Delete()
	Catch
		'View is already deleted, go to the next one
	End try

Next

tempSheet.Activate() 'Activate temporary sheet
oThread.Join(oThreadTime) 'Needed to properly switch to the sheet

'Select all views on temporary sheet
For Each oDrawingView In tempSheet.DrawingViews

	oDrawDoc.SelectSet.Select(oDrawingView)

Next

ThisApplication.CommandManager.ControlDefinitions.Item("AppCopyCmd").Execute() 'Copy views
'oThread.Join(oThreadTime) 'OPTIONAL IF NEEDED

mainSheet.Activate() 'Go to main sheet
oThread.Join(oThreadTime) 'Needed to properly switch  to the sheet

ThisApplication.CommandManager.ControlDefinitions.Item("AppPasteCmd").Execute() 'Paste views
oThread.Join(oThreadTime) 'Needed to give time to paste

tempSheet.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 views
drawingViewsCountAfter = mainSheet.DrawingViews.Count


undo.End 'End undo transaction


If drawingViewsCountBefore <> drawingViewsCountAfter Then
	MessageBox.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()
	
	Exit Sub
	
End If

 

Example run:

ReneRepina_2-1616281041299.png

ReneRepina_3-1616281053010.png

 

RYWei
Explorer

I was able to achieve this in the following way:

 

1. Make a new sheet

2. Drag the non-desired view(s) onto that sheet, leaving only the view that you want the title block to reference

3. Drag all view BACK into the main sheet. 

Yijiang.Cai
Autodesk
Status changed to: Accepted

It has been tracked as [INVGEN-423].

stuartZCALS
Participant

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.

Yijiang.Cai
Autodesk
Status changed to: Implemented

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.

Right-click on Sheet and select Edit Sheet ...

Then in Text Property Source change the view that will be the source for the text in your title block.

Then click OK.

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea