05-18-2023
05:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
05-18-2023
05:53 AM
Here is an example of the issue in the Drawing environment. The progress bar seems to work well, but after running the rule, when I click on a sheet in the model tree the sheet changes all right but it doesn't highlight it any longer until I close the drawing and start over. If I add a new sheet it doesn't show in the model tree, until closing and re-opening that drawing. There seem to have been deeper and stranger issues too, with drawing not saving properly or views on sheets being raster etc. Yes, the code largely comes from the post on the first line as seen below.
' https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/ilogic-drawing-views-scale/td-p/3875879 Dim oDrawDoc As DrawingDocument = ThisDrawing.Document Dim oSheet As Sheet Dim oSheets As Sheets Dim oView As DrawingView Dim oViews As DrawingViews Dim oScale As String oActiveSheet = oDrawDoc.ActiveSheet
'oScale = InputBox("Enter Desired Scale", "Scaler", "1:1") oSheets = oDrawDoc.Sheets 'Create sheet counter variable Dim iSheetCount As Integer iSheetCount = 0 'Start a transaction Call ThisApplication.TransactionManager.StartTransaction(ThisDoc.Document, "Set Drawing View Scale") 'Progress bar oMessage = "Updating Drawing View Format" Dim SheetCount As Integer SheetCount = oDrawDoc.Sheets.Count Dim oProgressBar As Inventor.ProgressBar oProgressBar = ThisApplication.CreateProgressBar(False, SheetCount, oMessage) For Each oSheet In oSheets oSheet.Activate oViews = oSheet.DrawingViews 'Get the current sheet number iSheetCount = iSheetCount + 1 'Update the progress bar to reflect which sheet is being operated on oProgressBar.Message = ("Processing Sheet " & iSheetCount & " of " & SheetCount & "...") oProgressBar.UpdateProgress For Each oView In oViews If oView.ScaleFromBase = False Then Dim OrigScale As Double = 1/oView.Scale 'MessageBox.Show(OrigScale) Dim ScaleNumber As Double If OrigScale < 2 Then ScaleNumber = Format(OrigScale, "0.00") Else ScaleNumber = Format(OrigScale, "0") End If oView.Scale = 1 / ScaleNumber 'MessageBox.Show(ScaleNumber) End If Next Next oProgressBar.Close oActiveSheet.Activate