iLogic - Disabling section for parts from assembly level

iLogic - Disabling section for parts from assembly level

lukasz.badowski
Enthusiast Enthusiast
657 Views
4 Replies
Message 1 of 5

iLogic - Disabling section for parts from assembly level

lukasz.badowski
Enthusiast
Enthusiast

Hi Everyone,

 

I try do iLogic rule that disable participate sections for selected parts in assembly. Below picture with that what i mean.

Section.pngDocument Settings.png

Below is my rule. I try Set my setting for parts form ObjectCollection, and I receive some errors.

Can anyone get me some tips?

 

Dim oDocAssem As AssemblyDocument
oDocAssem = ThisApplication.ActiveDocument


Dim oSelected As ObjectCollection
oSelected = ThisApplication.TransientObjects.CreateObjectCollection

Dim oCount As Long
oCount = oDocAssem.SelectSet.Count

If oCount = 0 Then
	MessageBox.Show("Select one or more part.", "iLogic")
	Return
End If


Dim i As Integer
For i = 1 To oCount
	If oDocAssem.SelectSet.Item(i).Type = _
		ObjectTypeEnum.kComponentOccurrenceObject Then
		oSelected.Add (oDocAssem.SelectSet.Item(i))
	End If
Next


Dim oDoc As Document 
For Each oDoc In oSelected

Dim oPartDoc As PartDocument
oPartDoc = oDoc

  'Disable the part section.
  oPartDoc.ModelingSettings.AllowSectioningThruPart = False 


Next


MessageBox.Show("Done!", "iLogic")

 

0 Likes
Accepted solutions (2)
658 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor
Accepted solution

Try it this way.

 

Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
oSS = oADoc.SelectSet
If oSS.Count > 0 Then
	For i As Integer = 1 To oSS.Count
		If oSS.Item(i).Type = ObjectTypeEnum.kComponentOccurrenceObject Then
			Dim oComp As ComponentOccurrence = oSS.Item(i)
			If oComp.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
				Dim oPartDoc As PartDocument = oComp.Definition.Document
				oPartDoc.ModelingSettings.AllowSectioningThruPart = False
			End If
		End If
	Next
End If
MessageBox.Show("Done!", "iLogic")

 

I hope this helps.
If this solves your problem, or answers your questions, please click 'Accept As Solution".
Or, if this helps you reach your goal, please click 'LIKES" 👍.

 

Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.
If you agree with any of them, please vote for them.

  • Add more capabilities to the 'Customize' dialog box (exe. Add Tab & Add Panel) Click Here
  • Constrain & Dimension Images In Assembly Sketches & Drawing Sketches (TitleBlocks & SketchedSymbols) Click Here
  • Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) Click Here
  • Add SolidBodies Folder In iLogic Rule Editor Model Tab Click Here
  • Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder Click Here
  • SetDesignViewRepresentation - Fix limitations for DrawingView of a Part Click Here
  • Create DocumentSubTypeEnum Click Here
  • Add kRevisionTag or kDrawingRevisionTag to ObjectTypeEnum Click Here

Inventor 2020 Help | Inventor Forum | Inventor Customization Forum | Inventor Ideas Forum

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

lukasz.badowski
Enthusiast
Enthusiast

Hi,

 

It is not perfect solution, because selection more than one part makes error, but it is step forward and great tip.

 

0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor
Accepted solution

It might be more stable and work better for multiple selections if, instead of SelectSet, you used a Do While...Loop with the Pick command, which adds each Picked item to a ObjectCollection, until you answer No to a simple question (or select Nothing, or similar).

Then just define each object in the ObjectCollection as a ComponentOccurrence, before the loop to set the AllowSectioningThruPart setting.

Try it this way to see if it works any better for you.

Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oOC As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oObj As Object
Dim oContinue As Boolean = True
Dim oAns As MsgBoxResult

Do While oContinue = True
	oObj = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a Component Occurrence.")
	If oObj Is Nothing Then Exit Do
	oOC.Add(oObj)
	'oOC.Add(ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter))
	oAns = MsgBox("Do you want to add another selection?", vbYesNo + vbQuestion, "COMPONENT OCCURRENCES")
	If oAns = vbNo Then oContinue = False
Loop

For Each oObj In oOC
	Dim oCO As ComponentOccurrence = oObj
	If oCO.DefinitionDocumentType = DocumentTypeEnum.kPartDocumentObject Then
		Dim oPartDoc As PartDocument = oCO.Definition.Document
		oPartDoc.ModelingSettings.AllowSectioningThruPart = False
	End If
Next

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 5

lukasz.badowski
Enthusiast
Enthusiast

Hi WCrihfield,

 

Now it work perfect!

Thank You for help.

0 Likes