Ilogic rule - I have to run the rule twice.

Ilogic rule - I have to run the rule twice.

ralfmja
Advocate Advocate
289 Views
2 Replies
Message 1 of 3

Ilogic rule - I have to run the rule twice.

ralfmja
Advocate
Advocate

Hello,

 

I have a rule that does two things:
1. removes invisible lines from all views except the first one (“WIDOK1”)
2. Adds center lines on all views (after removing point 1)

 

The rule works, but you have to enable it twice because it only removes invisible lines in "one pass".

This is my code:

Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument	
Dim Arkusz As Sheet = ThisDrawing.Document.ActiveSheet
Dim ViewCount As Integer = oDrawingDoc.ActiveSheet.DrawingViews.Count
Dim StartCount As Integer = 0
Dim oview As DrawingView 

If Arkusz.DrawingViews.Count <> 0 Then 
      For StartCount = 1 To ViewCount
          	oview = Arkusz.DrawingViews.item(StartCount)
		   	aView = oview.Name
				If aView = "WIDOK1" Then
					ActiveSheet.View(aView).View.ViewStyle = 32257
					
				Else If aView = "WIDOK ISO" Then
					ActiveSheet.View(aView).View.ViewStyle = 32259
				Else 
					ActiveSheet.View(aView).View.ViewStyle = 32258
					ActiveSheet.View(aView).View.SetAutomatedCenterlineSettings()
				End If
       Next
End If
InventorVb.DocumentUpdate

 

I think it's a matter of some correct updating after completing point 1. But I've already tried splitting the loop, running the creation of centerlines as an additional external rule - it doesn't work.

 

Can anyone help me??

 

Regards,

ralfmja

0 Likes
Accepted solutions (1)
290 Views
2 Replies
Replies (2)
Message 2 of 3

lmc.engineering
Advocate
Advocate
Accepted solution

You are correct in that it's an issue with updating the views. The call to change base view style is updating the child/projected views also, and if the base view is 'hidden line removed' at the time of running the code seems to ignore the request for centrelines as the projected view is not up to date. You can try adding a loop to wait for the view update before proceeding:

Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim Arkusz As Sheet = ThisDrawing.Document.ActiveSheet
Dim ViewCount As Integer = oDrawingDoc.ActiveSheet.DrawingViews.Count
Dim StartCount As Integer = 0
Dim oview As DrawingView

If Arkusz.DrawingViews.Count <> 0 Then
	For StartCount = 1 To ViewCount
		oview = Arkusz.DrawingViews.Item(StartCount)
		aView = oview.Name
		If aView = "WIDOK1" Then
			oview.ViewStyle = 32257
		ElseIf aView = "WIDOK ISO" Then
			oview.ViewStyle = 32259
		Else
			oview.ViewStyle = 32258
			Do While oview.IsUpdateComplete = False
				ThisApplication.UserInterfaceManager.DoEvents
				ThisApplication.StatusBarText = "Updating drawing views..."
			Loop
			oview.SetAutomatedCenterlineSettings()
		End If
	Next
End If
InventorVb.DocumentUpdate

 

0 Likes
Message 3 of 3

ralfmja
Advocate
Advocate

Hi @lmc.engineering ,

 

Perfect 🙂 

 

Thank you very much 🙂

 

Regards,

ralfmja