I would like to know if there is a way to have each view name to be set to the orientation names/ the 3D view cube's name. Is there a way to do this without manually changing each one?
Solved! Go to Solution.
Solved by Dennis.Ossadnik. Go to Solution.
Hi jbauer,
you could manage this with a little macro like this:
Sub OrientationToLabel() Dim odoc As DrawingDocument Set odoc = ThisApplication.ActiveDocument 'active sheet Dim tmpSheet As Sheet Set tmpSheet = odoc.ActiveSheet Dim tmpView As DrawingView 'every draring view For Each tmpView In tmpSheet.DrawingViews Dim myDrawingViewName As String 'Which text for which orientation Select Case tmpView.Camera.ViewOrientationType Case ViewOrientationTypeEnum.kBackViewOrientation myDrawingViewName = "Back View" Case ViewOrientationTypeEnum.kBottomViewOrientation myDrawingViewName = "Bottom View" Case ViewOrientationTypeEnum.kFrontViewOrientation myDrawingViewName = "Front View" Case ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation myDrawingViewName = "Iso - Bottom Left View" Case ViewOrientationTypeEnum.kIsoBottomRightViewOrientation myDrawingViewName = "Iso - Bottom Right View" Case ViewOrientationTypeEnum.kIsoTopLeftViewOrientation myDrawingViewName = "Iso - Top Left View" Case ViewOrientationTypeEnum.kIsoTopRightViewOrientation myDrawingViewName = "Iso - Top Right View" Case ViewOrientationTypeEnum.kLeftViewOrientation myDrawingViewName = "Left View" Case ViewOrientationTypeEnum.kRightViewOrientation myDrawingViewName = "Right View" Case ViewOrientationTypeEnum.kTopViewOrientation myDrawingViewName = "Top View" Case Else myDrawingViewName = "" End Select 'Chang if view orientation was found If Not myDrawingViewName = "" Then 'change drawing view name tmpView.Name = myDrawingViewName End If Next End Sub
bofore:
After using the macro:
The macro will change the name of the drawing view of all view on that sheet.
You can adjust the code and replace the names of the orientation with names you like.
Do you think, this would work for you?
Please use the button "Accept as Solution" if it works.
When I paste this code into the iLogic Browser, I get an error message. I attached a screenshot image of it.
Hi jbauer,
sorry, i was not aware that you wanted to use it in iLogic. The code above is for using as a macro in VBA.
I changed the code. Now you should be able to use it with iLogic:
Here is the code for iLogic:
Sub Main() Dim odoc As DrawingDocument odoc = ThisApplication.ActiveDocument 'active sheet Dim tmpSheet As Sheet tmpSheet = odoc.ActiveSheet Dim tmpView As DrawingView 'every draring view For Each tmpView In tmpSheet.DrawingViews Dim myDrawingViewName As String 'Which text for which orientation Select Case tmpView.Camera.ViewOrientationType Case ViewOrientationTypeEnum.kBackViewOrientation myDrawingViewName = "Back View" Case ViewOrientationTypeEnum.kBottomViewOrientation myDrawingViewName = "Bottom View" Case ViewOrientationTypeEnum.kFrontViewOrientation myDrawingViewName = "Front View" Case ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation myDrawingViewName = "Iso - Bottom Left View" Case ViewOrientationTypeEnum.kIsoBottomRightViewOrientation myDrawingViewName = "Iso - Bottom Right View" Case ViewOrientationTypeEnum.kIsoTopLeftViewOrientation myDrawingViewName = "Iso - Top Left View" Case ViewOrientationTypeEnum.kIsoTopRightViewOrientation myDrawingViewName = "Iso - Top Right View" Case ViewOrientationTypeEnum.kLeftViewOrientation myDrawingViewName = "Left View" Case ViewOrientationTypeEnum.kRightViewOrientation myDrawingViewName = "Right View" Case ViewOrientationTypeEnum.kTopViewOrientation myDrawingViewName = "Top View" Case Else myDrawingViewName = "" End Select 'Chang if view orientation was found If Not myDrawingViewName = "" Then 'change drawing view name tmpView.Name = myDrawingViewName End If Next End Sub
Please use the button "Accept as Solution" if it works.
Thanks.
hi 🙂
work great, but is you have a section in your drawing, put side view in view label name????
Hey Dennis, nice bit of code - works really well! Would it be difficult to modify it to ignore detail and section views? At the moment if you have any in the drawing they get modified too so you wind up with things like "DETAIL TOP" and "LEFT-LEFT SECTION"!
Cheers,
Kevin
Hi Kevin,
could you please give this code a try:
VBA:
Sub IDW_OrientationToLabel() Dim odoc As DrawingDocument Set odoc = ThisApplication.ActiveDocument 'active sheet Dim tmpSheet As Sheet Set tmpSheet = odoc.ActiveSheet Dim tmpView As DrawingView For Each tmpView In tmpSheet.DrawingViews Dim myDrawingViewName As String If tmpView.Type = kDrawingViewObject Then 'Which text for which orientation Select Case tmpView.Camera.ViewOrientationType Case ViewOrientationTypeEnum.kBackViewOrientation myDrawingViewName = "Back View" Case ViewOrientationTypeEnum.kBottomViewOrientation myDrawingViewName = "Bottom View" Case ViewOrientationTypeEnum.kFrontViewOrientation myDrawingViewName = "Front View" Case ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation myDrawingViewName = "Iso - Bottom Left View" Case ViewOrientationTypeEnum.kIsoBottomRightViewOrientation myDrawingViewName = "Iso - Bottom Right View" Case ViewOrientationTypeEnum.kIsoTopLeftViewOrientation myDrawingViewName = "Iso - Top Left View" Case ViewOrientationTypeEnum.kIsoTopRightViewOrientation myDrawingViewName = "Iso - Top Right View" Case ViewOrientationTypeEnum.kLeftViewOrientation myDrawingViewName = "Left View" Case ViewOrientationTypeEnum.kRightViewOrientation myDrawingViewName = "Right View" Case ViewOrientationTypeEnum.kTopViewOrientation myDrawingViewName = "Top View" Case Else myDrawingViewName = "" End Select 'Change if view orientation was found If Not myDrawingViewName = "" Then 'change drawing view name tmpView.Name = myDrawingViewName End If End If myDrawingViewName = "" Next End Sub
iLogic:
'active sheet Dim tmpSheet As Sheet = ThisDrawing.ActiveSheet.Sheet Dim tmpView As DrawingView For Each tmpView In tmpSheet.DrawingViews Dim myDrawingViewName As String = "" If tmpView.Type = ObjectTypeEnum.kDrawingViewObject Then 'Which text for which orientation Select Case tmpView.Camera.ViewOrientationType Case ViewOrientationTypeEnum.kBackViewOrientation myDrawingViewName = "Back View" Case ViewOrientationTypeEnum.kBottomViewOrientation myDrawingViewName = "Bottom View" Case ViewOrientationTypeEnum.kFrontViewOrientation myDrawingViewName = "Front View" Case ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation myDrawingViewName = "Iso - Bottom Left View" Case ViewOrientationTypeEnum.kIsoBottomRightViewOrientation myDrawingViewName = "Iso - Bottom Right View" Case ViewOrientationTypeEnum.kIsoTopLeftViewOrientation myDrawingViewName = "Iso - Top Left View" Case ViewOrientationTypeEnum.kIsoTopRightViewOrientation myDrawingViewName = "Iso - Top Right View" Case ViewOrientationTypeEnum.kLeftViewOrientation myDrawingViewName = "Left View" Case ViewOrientationTypeEnum.kRightViewOrientation myDrawingViewName = "Right View" Case ViewOrientationTypeEnum.kTopViewOrientation myDrawingViewName = "Top View" Case Else myDrawingViewName = "" End Select 'Change if view orientation was found If Not myDrawingViewName = "" Then 'change drawing view name tmpView.Name = myDrawingViewName End If End If myDrawingViewName = "" Next
Better now?
Hello,
I have a 'twist' on this thread.
In the model representations you can create views. Is it possible to collect and use the name of the view in the title block of a sheet?
Dennis,
im into a problem with your code. when i create the Left View it labels it as Front View and Front View as Right View.
Thanks,
Jeremy
Hi! I guess you may need to check your Style setting and see if the view is based on model XY plane or Front. Open the idw/dwg file and go to Manage -> Styles Editor -> View Preference -> Front View Plane. Is it set to "From Model" or one of the origin planes?
Many thanks!
Johnson,
thank you, thats what it is my work computer is set to "XY" and not "From Model".
is there any way i can work around this leaving it set as "XY" ?
Thanks,
Jeremy
Hi! I guess it may work but you will have to modify the code/rule so that it is changing the view you want to change. It can be a bit tricky.
Many thanks!
I am using this Code and its working well for me. I was just wondering if there was a way to update the rule so that the view label scale is overridden to show NTS for the ISO views? I have tried unsuccessfully.
Is it normal that you have to "Regenerate All Rules" before this takes effect? Or did i do something wrong?
Hi @marcel.coufreur. That should not be needed. However, you may just need to add an extra line of code in there at the end to update the drawing document before you will see the changes. If using an internal iLogic rule, you can use the line:
InventorVb.DocumentUpdate
...for that purpose. Or if using VBA, you would use the variable for the document to update the document, similar to the following, where 'oDoc' is the variable that the DrawingDocument is assigned to:
oDoc.Update
There is also a setting within the Document Settings of drawings, on the Drawing tab, named 'Defer Updates', which may be on (checked). When that is checked, some changes will require you to click the update button before the changes will show on your screen.
https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=GUID-1E32149E-D99B-4875-AEEC-849A36DE5023
Wesley Crihfield
@WCrihfield Where exactly do I write this? I'm not really familiar with Ilogic.
Hi @marcel.coufreur. I am not sure which of the codes above you may be trying to use, but I was referring to an iLogic rule, not a VBA macro. If the code you are using starts with "Sub Main", and ends with "End Sub" (both unquoted), then you would need to put the code to update the document on a line just above the "End Sub". But if your code does not have those terms enclosing the code, you could just put the line of code for updating the document at the very end, on its own line. The "InventorVb.DocumentUpdate" line will only work within an iLogic rule, and will not be recognized in a VBA macro. But both iLogic and VBA would both recognize a line like the following.
ThisApplication.ActiveDocument.Update
But to explain a bit more about the 'regenerate rules' thing, I am not sure there is an official online help page for this, but it is basically used to reconnect parameter recognition within internal iLogic rules. What that means is, when the iLogic rule is an internal one (saved within an Inventor document), and you include the unquoted names of parameters (that exist within that same document) within that rule, that will cause the rule to be triggered to run any time the value of any of those parameters changes. Sometimes either that triggering action, or the rule's ability to recognize that unquoted parameter name as representing a parameter gets broken some reason, clicking that tool will fix that association, recognition, and triggering behavior.
Below is a link to some online help documentation that mentions this.
To Work with Rules in iLogic (and scroll to the heading "Run Rules", where this is mentioned)
You can also see a description of it when you hover your mouse over the Regenerate All Rules button for a while.
When you use that tool, not only will it try to fix any problems, but it will run all of the internal iLogic rules within that document, and within any referenced documents too. So be very careful using that tool while a large assembly may be open on your screen, and it may contain many other components that contain some internal iLogic rules.
Wesley Crihfield
@WCrihfield right now I have this.
Sub Main() 'active sheet Dim tmpSheet As Sheet = ThisDrawing.ActiveSheet.Sheet Dim tmpView As DrawingView For Each tmpView In tmpSheet.DrawingViews Dim myDrawingViewName As String = "" If tmpView.Type = ObjectTypeEnum.kDrawingViewObject Then 'Which text for which orientation Select Case tmpView.Camera.ViewOrientationType Case ViewOrientationTypeEnum.kBackViewOrientation myDrawingViewName = "Achteraanzicht" Case ViewOrientationTypeEnum.kBottomViewOrientation myDrawingViewName = "Onderaanzicht" Case ViewOrientationTypeEnum.kFrontViewOrientation myDrawingViewName = "Vooraanzicht" Case ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation myDrawingViewName = "3D indruk" Case ViewOrientationTypeEnum.kIsoBottomRightViewOrientation myDrawingViewName = "3D indruk" Case ViewOrientationTypeEnum.kIsoTopLeftViewOrientation myDrawingViewName = "3D indruk" Case ViewOrientationTypeEnum.kIsoTopRightViewOrientation myDrawingViewName = "3D indruk" Case ViewOrientationTypeEnum.kLeftViewOrientation myDrawingViewName = "Linker zijaanzicht" Case ViewOrientationTypeEnum.kRightViewOrientation myDrawingViewName = "Rechter zijaanzicht" Case ViewOrientationTypeEnum.kTopViewOrientation myDrawingViewName = "Bovenaanzicht" Case Else myDrawingViewName = "" End Select 'Change if view orientation was found If Not myDrawingViewName = "" Then 'change drawing view name tmpView.Name = myDrawingViewName End If End If myDrawingViewName = "" Next ThisApplication.ActiveDocument.Update End Sub
But It doesn't automatically update what am I missing?
Hi @marcel.coufreur. I slightly edit your code a bit in an attempt to maybe being able to help with the updating. The terms 'ThisDrawing' and 'ThisApplication.ActiveDocument' can potentially be pointing to two different documents in certain situations, so eliminated both terms, and am now using the 'ThisDoc.Document' term to refer to the drawing document in the first two lines, then once I store that document reference to a variable (oDDoc), I use that same document variable at the end, to make sure I am working with the exact same document. I also included a line to update the drawing sheet itself. And I am using an Inventor API method of that document to update it directly, while accepting any errors that might arise, and continue. I am also checking a related Document Setting within that drawing called Defer Updates, and if it is turned ON, that code will turn it OFF. Give this a try, and hopefully it will update better for you.
Sub Main()
If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub
Dim oDDoc As DrawingDocument = ThisDoc.Document
If oDDoc.IsModifiable = False Then
MsgBox("This drawing is not modifiable. Exiting rule.", , "")
Exit Sub
End If
If oDDoc.DrawingSettings.DeferUpdates = True Then
oDDoc.DrawingSettings.DeferUpdates = False
End If
Dim oSheet As Inventor.Sheet = oDDoc.ActiveSheet
Dim oViews As DrawingViews = oSheet.DrawingViews
For Each oView As DrawingView In oViews
Select Case oView.Camera.ViewOrientationType
Case ViewOrientationTypeEnum.kBackViewOrientation
oView.Name = "Achteraanzicht"
Case ViewOrientationTypeEnum.kBottomViewOrientation
oView.Name = "Onderaanzicht"
Case ViewOrientationTypeEnum.kFrontViewOrientation
oView.Name = "Vooraanzicht"
Case ViewOrientationTypeEnum.kIsoBottomLeftViewOrientation
oView.Name = "3D indruk"
Case ViewOrientationTypeEnum.kIsoBottomRightViewOrientation
oView.Name = "3D indruk"
Case ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
oView.Name = "3D indruk"
Case ViewOrientationTypeEnum.kIsoTopRightViewOrientation
oView.Name = "3D indruk"
Case ViewOrientationTypeEnum.kLeftViewOrientation
oView.Name = "Linker zijaanzicht"
Case ViewOrientationTypeEnum.kRightViewOrientation
oView.Name = "Rechter zijaanzicht"
Case ViewOrientationTypeEnum.kTopViewOrientation
oView.Name = "Bovenaanzicht"
Case Else
End Select
Next 'oView
'update the sheet
oSheet.Update
'update the drawing, True = accept any errors and continue
oDDoc.Update2(True)
End Sub
...and by the way, that 'Defer Updates' setting can be found manually by going to the Tools tab > Options panel > click the Document Settings tool, activate the Drawing tab within that dialog, and there is a checkbox for that setting near the top left of that dialog.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield