iLogic Rule to Turn-On Frame Generator Part Start Plane and End Plane

iLogic Rule to Turn-On Frame Generator Part Start Plane and End Plane

cadman777
Advisor Advisor
1,304 Views
17 Replies
Message 1 of 18

iLogic Rule to Turn-On Frame Generator Part Start Plane and End Plane

cadman777
Advisor
Advisor

Hello Experts,

I'm trying to make an angle dimension on the end of a part that's mitered so the chop saw guys can set the saw angle.

However, Inventor doesn't have a way to do this out-of-the-box.

Last week I inquired in here of an alternative way to do this, but it didn't work.

So now I'm inquiring to see if someone has an iLogic rule they are willing to share, or can make one and share it with me, that turns-on a FrameGenerator part's StartPlane and EndPlane.

Any help is much appreciated!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Accepted solutions (1)
1,305 Views
17 Replies
Replies (17)
Message 2 of 18

A.Acheson
Mentor
Mentor

Hi @cadman777 

I don't have a rule ready but we can create one from first principles and you hopefully can do it in future ones. 

1. To start with what is the name or unique iproperty of the occurrence you want to target. I assume you don't want to turn on them all so maybe a description, part number or you want to manually select? 

2. What are the names of the workplanes your targeting? I know one is the origin but this can be any origin if it's a custom author. Does it have another or is it simply an extrusion?

 

So the workplane collection is access from the component definition object which in turn is accessed from the component occurrence if in an assembly. This order is working backwards from the object you want to control but usually you would work top down through each object.

 

1. You can get part component occurrence in many ways, user picking, looping through leaf occurrences from the assembly document etc

Here is the pick command, change the enum as needed.

 

Here is leaf occurrences. 

 

Syntax AssemblyDocument.ComponentDefinition() As AssemblyComponentDefinition Syntax

ComponentDefinition.Occurrences() As ComponentOccurrences

 

Syntax

ComponentOccurrences.AllLeafOccurrences( [LeafDefinition] As Variant ) As ComponentOccurrencesEnumerator

 

So you will need to declare it as a part component definition to have it pop up on the menu.

Syntax

ComponentOccurrence.Definition() As ComponentDefinition

 

Syntax

PartComponentDefinition.WorkPlanes() As WorkPlanes

 

 

 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 18

cadman777
Advisor
Advisor

Thanks for this info, Alan.

This is just what I want to know.

I don't have time today to dive into this, but will as soon as I get a 'break in the action'.

Then I'll get right back to you on this.

Cheers!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 4 of 18

cadman777
Advisor
Advisor

To clarify you can go to this thread.

Just look at the pics in Message 1.

These are 'single part' details on an Inventor idw drawing.

They are all packed onto a single sheet (or as many sheets as are necessary).

These parts are all FrameGenerator parts.

The objective is to Run the iLogic rule, then select the single part drawing view that needs angle dimensions, and then the iLogic rule will automatically turn on the StartPlane and EndPlane. And it will continuously run until ESC is pressed or another command is selected. That way, I don't have to press enter or keep restarting the rule for the many single part details on each drawing sheet. This rule will help me add angle dimensions to the miter the way the shop guys need to see it. At present I'm creating a drawing Sketch on every view, then Projecting the long sides of the part, then adding a very short hash mark at both vertices, then finishing the Sketch an adding angle dimensions (which requires zooming-in very close to see the hash mark, and then zooming out to finish the angle dimension. I have to do all that for each end of every part that's mitered. This was an idea that @blandb suggested in the above link.

So I won't be doing this with an assembly, only single parts, and only on an idw drawing.

Here's where I started in my quest for info on this.

Then I went here.

And here.

Thanks...

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 5 of 18

A.Acheson
Mentor
Mentor

Hi @cadman777 Thanks for the clarification. because your now in a drawing you have increased the complexity further. The below is the equivalent of 

AAcheson_0-1698957372978.png

Syntax

DrawingView.SetIncludeStatus( Object As Object, Include As Boolean )

 

and this will allow you to find if it has allready being set

Syntax

DrawingView.GetIncludeStatus( Object As Object ) As Boolean

 

Rough workflow

To get here you will need a drawing curve segment then get the occurrence then the workplane and assuming it's just a part your working with give the workplane object to the below Set include method. 

 

The alternative is just assume you have one part document and from the view get the model document and from there go direct to workplane. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 6 of 18

cadman777
Advisor
Advisor

This is probably the best pathway:

The alternative is just assume you have one part document and from the view
get the model document and from there go direct to workplane.
... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 7 of 18

A.Acheson
Mentor
Mentor

In that case you can use the first views model document and the ilogic function is "ThisDoc.ModelDocument" see ilogic API Help here

 

 

Dim partDoc as PartDocument = ThisDoc.ModelDocument

 

 Once you have this then use the same technique as workplane retrieval in the part document. Test you have the correct object by getting its name. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 8 of 18

cadman777
Advisor
Advisor

OK, lemme work on it and get back to you.

Thanks!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 9 of 18

cadman777
Advisor
Advisor

UPDATE:

I re-read this thread and think you still may not understand what I want to accomplish.

Picture this: There is a drawing with 40 single part details on it, all of which are FrameGenerator parts.

Each detail has 3 views: end, right side, right top.

I want an iLogic rule that I can start, and then click on the right view (or whatever view is necessary), resulting in the StartPlane and EndPlane turning-on. Then the Rule will continue to run so I can continue to pick view after view, until all the views on the sheet that need the work planes showing are changed. And when any other command, or ESC, or ENTER is activated, then Rule stops running.

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 10 of 18

A.Acheson
Mentor
Mentor

Hi @cadman777

In that case you cannot use the simple ilogic snippet to pick up the model document. This only works if you have one model document per drawing file. Try the below. Adjust the workplane index if the workplane isn't visible. You can also give the name of the workplane as a string ( "1234")

Dim drawView As DrawingView = ThisApplication.CommandManager.Pick(selectionfilterenum.kDrawingViewFilter, "Pick View")

Dim partDoc As PartDocument = drawView.ReferencedDocumentDescriptor.ReferencedDocument
Dim wp As WorkPlane = partDoc.ComponentDefinition.WorkPlanes(1)

drawView.SetIncludeStatus(wp, True)
       
    
 
 
If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 11 of 18

cadman777
Advisor
Advisor

OK, I looked at this and tried it.

I keep forgetting that I have Inventor 2010.

So I need a solution for user selection ("pick") in a drawing (the view or a line to i.d. the part).

It was mentioned in my other thread, but I never was able to figure it out.

Any chance you can link me to that info?

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 12 of 18

A.Acheson
Mentor
Mentor

A simple way around that is to pick the view before starting the rule using select set. This was the orgional item selection in VBA. See  example here and object help page here

Dim selectSet As SelectSet = ThisDoc.Document.SelectSet
Dim drawView As DrawingView
If Typeof selectSet.Item(1) Is DrawingView Then  
  drawView = selectSet.Item(1)  
  Messagebox.Show(drawView.Name)
End If

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 13 of 18

cadman777
Advisor
Advisor

Excellent, thanks.

So that means I have to do a Loop that inputs the name of each selected view, right?

But if I select them one at a time, then how would I do it if I only select one view instead of selecting all the views before Running the Rule?

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 14 of 18

A.Acheson
Mentor
Mentor
Accepted solution

Here is the working code. SelectSet is an object collection so you just need to loop through the collection to work with each object. 

Dim selectSet As SelectSet = ThisDoc.Document.SelectSet

'Do single selection
While selectSet.Count = 0
	ThisApplication.UserInterfaceManager.DoEvents
End While

For Each sel In selectSet

	Dim drawView As DrawingView

	If TypeOf sel Is DrawingView Then  
	  	drawView = sel  
		Dim partDoc As PartDocument = drawView.ReferencedDocumentDescriptor.ReferencedDocument
		Dim wp As WorkPlane = partDoc.ComponentDefinition.WorkPlanes("XY Plane")
		
		Try
			drawView.SetIncludeStatus(wp, True)
		Catch
		End Try
		
	End If
	
Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 15 of 18

cadman777
Advisor
Advisor

Hi Alan,

Thanks for writing that code for me!

Funny thing is, I had time this morning to try my hand at this.

Here is what I got to work:

' Mentor A.Acheson in reply to: cadman777 - <u+200e>11-05-2023 11:47 AM 
' Adjust the workplane index if the workplane isn't visible.
' View must be picked before running this rule
Dim Done As Boolean = False
Dim dv As DrawingView
Dim selectSet As SelectSet = ThisDoc.Document.SelectSet
If TypeOf selectSet.Item(1) Is DrawingView Then  
  dv = selectSet.Item(1)  
' Messagebox.Show(dv.Name)
Dim partDoc As PartDocument = dv.ReferencedDocumentDescriptor.ReferencedDocument
Dim wp As WorkPlane = partDoc.ComponentDefinition.WorkPlanes(1)
Dim wp1 As WorkPlane = partDoc.ComponentDefinition.WorkPlanes.Item("Start Plane")
Dim wp2 As WorkPlane = partDoc.ComponentDefinition.WorkPlanes.Item("End Plane")
	dv.SetIncludeStatus(wp1, True)
	dv.SetIncludeStatus(wp2, True)
'	SelectMore = MsgBox("Want to pick another view?", vbYesNo, "Pick more...")
'If SelectMore = vbYes Then
'	Done = False
'Else
	Done = True
End If
'End If

Thing is, I couldn't use the 'Do' b/c it needs a final 'Loop', which sent it into a perpetual loop.

I looked up online and discovered that there's no way to end a loop except the way I did it: CTRL+ALT+DEL>End Task!

So I combined both your codes and some other stuff I found online and got it to work.

Horray!

But, I still have to pick the view before running the Rule.

And if I pick multiple views, it only works on one view.

So then I have to start the process again.

Anyway, let me try your code and see if it works better!

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 16 of 18

cadman777
Advisor
Advisor

Yup, that did it.

That's what the rule needed to rifle through the picked views.

Here's my slight modification to your rule so it turns-on the StartPlane & EndPlane on FG parts:

 

 

 

' Mentor A.Acheson in reply to: cadman777 - 11-07-2023 08:11 PM 
' Here is the working code
' SelectSet is an object collection so you just need to loop through the collection to work with each object.
' Adjust the workplane index if the workplane isn't visible.
' View must be picked before running this rule

Dim selectSet As SelectSet = ThisDoc.Document.SelectSet

'Do single selection
While selectSet.Count = 0
	ThisApplication.UserInterfaceManager.DoEvents
End While

For Each sel In selectSet

	Dim drawView As DrawingView

	If TypeOf sel Is DrawingView Then  
	  	drawView = sel  
		Dim partDoc As PartDocument = drawView.ReferencedDocumentDescriptor.ReferencedDocument
'		Dim wp As WorkPlane = partDoc.ComponentDefinition.WorkPlanes("XY Plane")
		Dim wp1 As WorkPlane = partDoc.ComponentDefinition.WorkPlanes.Item("Start Plane")
		Dim wp2 As WorkPlane = partDoc.ComponentDefinition.WorkPlanes.Item("End Plane")

		Try
'			drawView.SetIncludeStatus(wp, True)
			drawView.SetIncludeStatus(wp1, True)
			drawView.SetIncludeStatus(wp2, True)

		Catch
		End Try
		
	End If
	
Next

 

 

 

Many thanks for your able assistance!

 

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes
Message 17 of 18

A.Acheson
Mentor
Mentor

Glad to hear you got it functioning. I think Michael helped you out with another version without pick function  I didn't get a chance to study but it relies on events so might have the ability to select multiples after rule starts. 

 

https://forums.autodesk.com/t5/inventor-programming-ilogic/angle-dimension-to-virtual-perpendicular/...

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 18 of 18

cadman777
Advisor
Advisor

Yeah, I tried it, but it threw a list of errors that I didn't have the mind to figure out...

... Chris
Win 7 Pro 64 bit + IV 2010 Suite
ASUS X79 Deluxe
Intel i7 3820 4.4 O/C
64 Gig ADATA RAM
Nvidia Quadro M5000 8 Gig
3d Connexion Space Navigator
0 Likes