Showing posts with label Work Point. Show all posts
Showing posts with label Work Point. Show all posts

Monday, October 10, 2022

Traverse Assembly to Turn Off all Work Features and Sketches with iLogic



Issue:
An update to an older post on this topic:
http://inventortrenches.blogspot.com/2013/03/turn-onoff-all-workfeatures-with-ilogic.html

Solution:
You can use this example iLogic rule to traverse the assembly (and subassemblies) to turn off all work features and sketches.


Sub Main

	Dim oDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oOccs As ComponentOccurrences = oDoc.ComponentDefinition.Occurrences

	Dim sName As String
	sName = oDoc.DisplayName

	'set vis in the top level
	Call SetVis(oDoc, sName)

	Call TraverseAssembly(oOccs)

End Sub

Sub TraverseAssembly(oOccs As ComponentOccurrences)

	Dim oOcc As ComponentOccurrence
	For Each oOcc In oOccs

		Dim oDoc As Document
		oDoc = oOcc.Definition.Document

		Dim sName As String
		sName = oOcc.Name

		'set vis in the component
		Call SetVis(oOcc.Definition.Document, sName)

		'if sub assembly step into it's Occurrences collection
		If oOcc.DefinitionDocumentType = _
				DocumentTypeEnum.kAssemblyDocumentObject Then
			Logger.Info("Stepping into: " & sName)
			
			oSubOccs = oDoc.ComponentDefinition.Occurrences
			Call TraverseAssembly(oSubOccs)
		End If
	Next

End Sub

Sub SetVis(oDoc As Document, sName As String)

	Dim oDef As ComponentDefinition
	oDef = oDoc.ComponentDefinition


	For Each oItem In oDef.Workplanes
		Try
			oItem.visible = False
		Catch
			Logger.Info("Could not set work plane vis for: " & sName)
		End Try
	Next

	For Each oItem In oDef.WorkAxes
		Try
			oItem.visible = False
		Catch
			Logger.Info("Could not set work axis vis for: " & sName)
		End Try
	Next

	For Each oItem In oDef.WorkPoints
		Try
			oItem.visible = False
		Catch
			Logger.Info("Could not set work point vis for: " & sName)
		End Try
	Next

	For Each oItem In oDef.Sketches
		Try
			oItem.visible = False
		Catch
			Logger.Info("Could not set sketch vis for: " & sName)
		End Try
	Next

End Sub

Saturday, February 5, 2011

Round Peg in a Square Hole: Autodesk Inventor Work Points, Axis and Surfaces

Issue:
You have a square cutout in which you need to constrain a round bolt.

Solution:
You can can use a work axis to constrain to, or you can create a work surface from a sketch. In either case once you constrain to them, you can toggle the work geometry's visibility off.

In this video tutorial three methods are demonstrated. 
  • In the first a work point is created using the Loop Select option, then a work axis is created by selecting the work point and the face of the part. 
  • In the second method work point and axis are created in reverse order. A work axes is created, by creating an "in step" work point. 
  • In the third method a sketch is extruded as a surface. 
Note: the actual video quality is better than this thumbnail preview appears.



The advantage of the work surface is that an insert constraint can be used at the assembly level, where as with the work axis a center line mate constraint and an additional constraint would be used.