iLogic check whether drawing view is associative, set to particular one, Display Option - Thread Feature true, Tangent Edges true, ....

engilic
Advocate
Advocate

iLogic check whether drawing view is associative, set to particular one, Display Option - Thread Feature true, Tangent Edges true, ....

engilic
Advocate
Advocate

Hi,

 

Would like to check whether a certain Drawing View Representation exists, if yes, and if Dwawing View Representation not set to that one then set it.
Also whether Display Option - Thread Feature true, if not set it true, and same for Display Option - Tangent Edges, but opposite for Foreshortened, set it to false.
Do this for all views that are selected and if no view selected goes through all views on all sheets and do it.


Algorithm attached.

 

Thank you.

 

Have a lovely day.

0 Likes
Reply
Accepted solutions (2)
1,659 Views
7 Replies
Replies (7)

dutt.thakar
Collaborator
Collaborator
Accepted solution

@engilic 

 

Try the below code and see if it works, This rule is iterating through each view in a drawing sheet and setting view rep ta specific one, making it associative, also checking and changing the display options as you have asked for.

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oRep As String = "ViewRep1" ' Type in the name of View rep that you want to search set in each oView

For Each oView As DrawingView In oSheet.DrawingViews
	If Not oView.ActiveDesignViewRepresentation Is oRep
		oView.SetDesignViewRepresentation(oRep, True)
	End If
	
	If oView.DisplayTangentEdges = False
		oView.DisplayTangentEdges = True
		If oView.DisplayForeshortenedTangentEdges = True
			oView.DisplayForeshortenedTangentEdges = False
		End If 
	End If
	
	If oView.DisplayThreadFeatures = False
		oView.DisplayThreadFeatures = True
	End If
Next

 Hope this is helpful.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn

dutt.thakar
Collaborator
Collaborator

@engilic 

 

If you are happy with above reply please accept it as a solution.

If this answer has solved your problem please ACCEPT SOLUTION and hit like if you found it helpful..!


Regards,
Dutt Thakar
LinkedIn

engilic
Advocate
Advocate

Thank you @dutt.thakar

 

No time to check the code but from what I saw, I think it will work.

 

Maybe you can add few more lines for me.

 

How to set View / Style to be Style from Base and then those 3 options Hidden Line / Hidden Line Removed / Shaded.

 

Is there any way to find how to do it for all View Settings, is there any list of those parameters/objects, actually is there a list of all parameters/objects for any possible option/setting in Inventor.

What is the best way to find it when I need to set some option, not to bother you through the forum, or maybe Autodesk won't give us the list because they want their forum to be more active ;-)?

 

The bigger question is how to check whether any object is selected on the drawing and then whether some of them are views, if there are views selected then go through all the views and apply the code, otherwise I will say to go through all views on all sheets? I have one code that does a similar thing, makes a set of objects, just do not know how to check if the object is a view.

 

Thank you

0 Likes

WCrihfield
Mentor
Mentor

Here is the link to Inventor's online help page for the DrawingView object.

On this page, you'll see most of the things we can do with that Type of object using iLogic's built-in functionality.

There are lots of stuff to read through and sub-links to all its Properties and Methods.

This should be a good start.

 

Also, I don't know if you are aware of these, or if you've used them before, but the iLogic 'Snippets' are also a great place to see a lot of examples of how to do most of the most common stuff in iLogic.  To access them, open your iLogic Rule Editor dialog (by either creating a new rule, or editing an existing one).  Then on the far left of that dialog window you should see a side docked area labeled "Snippets" at the top.  There are two tabs under its heading. One named "System", and one named "Custom".  The one named "System" is where Inventor puts all its standard (installed with Inventor) snippets.  The other tab is for your own custom snippets later.  Explore all those snippets.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click 'LIKE' 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

engilic
Advocate
Advocate

Thank you @WCrihfield ,

 

I knew there is something like that but wasn't sure how to find it.

0 Likes

engilic
Advocate
Advocate

This is my code, still not fully tested.

 

Thank you @dutt.thakar .

 

Sub Main()

Dim oDoc As DrawingDocument = ThisApplication.ActiveEditDocument
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView
Dim oViewRepresentation As String = "Default" 'VIEW REPRESENTATION TO SET

'Dim oDrawDoc As DrawingDocument
'oDrawDoc = ThisApplication.ActiveEditDocument

'DETERMINE IF THERE ARE ANY VIEWS IN THE SELECT SET
Dim oSelectSet As SelectSet  = oDoc.SelectSet
Dim colViews As New Collection
Dim i As Long

For i = 1 To oSelectSet.Count
	If TypeOf oSelectSet.Item(i) Is DrawingView Then
		'ADD ANY VIEWS TO THE COLLECTION
		'WE NEED TO SAVE THEM IN SOMETHING BESIDES THE SELECTION SET BECAUSE ONCE WE START MANIPULATING THEM THE SELECT SET WILL BE CLEARED
		colViews.Add(oSelectSet.Item(i))
	End If
Next

If colViews.Count = 0 Then
	For Each oView In oSheet.DrawingViews
		ChangeView(oView, oViewRepresentation)
	Next
	
	Else
	For Each oView In colViews
		ChangeView(oView, oViewRepresentation)
	Next

End If

End Sub

Sub ChangeView(oView As DrawingView, oViewRepresentation As String)
	If Not oView.ActiveDesignViewRepresentation Is oViewRepresentation
		oView.SetDesignViewRepresentation(oViewRepresentation, True)
	End If

	If oView.DisplayTangentEdges = False
		oView.DisplayTangentEdges = True
		If oView.DisplayForeshortenedTangentEdges = True
			oView.DisplayForeshortenedTangentEdges = False
		End If 
	End If

	If oView.DisplayThreadFeatures = False
		oView.DisplayThreadFeatures = True
	End If	
End Sub

 

0 Likes

engilic
Advocate
Advocate
Accepted solution

final:

 

Sub Main()

Dim oDoc As DrawingDocument = ThisApplication.ActiveEditDocument
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView
Dim oViewRepresentation As String = "Default" 'VIEW REPRESENTATION TO SET

'DETERMINE IF THERE ARE ANY VIEWS IN THE SELECT SET
Dim oSelectSet As SelectSet  = oDoc.SelectSet
Dim colViews As New Collection
Dim i As Long

For i = 1 To oSelectSet.Count
	If TypeOf oSelectSet.Item(i) Is DrawingView Then
		'ADD ANY VIEWS TO THE COLLECTION
		'WE NEED TO SAVE THEM IN SOMETHING BESIDES THE SELECTION SET BECAUSE ONCE WE START MANIPULATING THEM THE SELECT SET WILL BE CLEARED
		colViews.Add(oSelectSet.Item(i))
	End If
Next

If colViews.Count = 0 Then

	For Each oView In oSheet.DrawingViews
		ChangeView(oView, oViewRepresentation)
	Next

	Else
	For Each oView In colViews
		ChangeView(oView, oViewRepresentation)
	Next

End If

End Sub

Sub ChangeView(oView As DrawingView, oViewRepresentation As String)

	If Not oView.ActiveDesignViewRepresentation Is oViewRepresentation Then
		Try
			oView.SetDesignViewRepresentation(oViewRepresentation, True)
		Catch
		End Try
	End If

	If oView.DisplayTangentEdges = False Then
		Try
			oView.DisplayTangentEdges = True
		Catch
		End Try
		If oView.DisplayForeshortenedTangentEdges = True Then
			Try
				oView.DisplayForeshortenedTangentEdges = False
			Catch
			End Try
		End If
	End If

	If oView.DisplayThreadFeatures = False Then
		Try
			oView.DisplayThreadFeatures = True
		Catch
		End Try
	End If

End Sub