iLogic code for HoleFeature

iLogic code for HoleFeature

tobias
Collaborator Collaborator
785 Views
4 Replies
Message 1 of 5

iLogic code for HoleFeature

tobias
Collaborator
Collaborator

Hi,

 

I have an assembly with a lot of individual plates with mounting holes.

The holes (Hole1) are all the same in each plate. Now I need to modify all holes 

to a smaller diameter. Can somebody help me with an iLogic code for this ?

 

tobias_0-1668505585904.png

 

 

Thanks

 

 

Tobias
The Netherlands
Inventor Pro 2026, Vault Pro 2026, AutoCad Electrical 2026.

If a response answers your question, please use ACCEPT SOLUTION to assist other users later.
0 Likes
Accepted solutions (1)
786 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @tobias.  Were all of the hole features placed into the components at the top assembly level, or were they created within the parts themselves (Do the hole features reside directly in the assembly only, or are they only in the parts)?  In the image that you posted, are those the current dimensions of the existing hole features?  ...Or are those the dimensions that you want to change the hole features to?  If those are the current dimensions of the hole features, then what dimensions to you want to change them to?  Are the parts with those hole features the only parts in the assembly?  If there are other parts in the assembly, then how can we identify these parts amongst the others when looking through the assembly by code?  Are these hole features patterned?  If so, how were they patterned...by a sketch of center points, or by patterning the feature into a pattern of the original feature?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 5

tobias
Collaborator
Collaborator

Hi @WCrihfield ,

 

The holes are created in inside the parts. There are no holes features inside the assembly.

 

Yes, the picture shows the current dimensions. Those dimensions I want to modify 

to e.g. 5 mm diameter and 10 mm countersink.

 

The code can check all parts, and checks if it has a hole feature e.g. "Hole1"

If the it has a hole feature with a diameter of 7 and a countersink of 12 then 

modify it to a diameter of 5 and a countersink of 10.

 

The holes are not patterned.

 

Thanks

 

 

 

Tobias
The Netherlands
Inventor Pro 2026, Vault Pro 2026, AutoCad Electrical 2026.

If a response answers your question, please use ACCEPT SOLUTION to assist other users later.
0 Likes
Message 4 of 5

WCrihfield
Mentor
Mentor
Accepted solution

OK @tobias.  I think I may have something that should work for that scenario then.  See if this works OK for you.

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
	MsgBox("An Assembly Document must be active for this rule to work. Exiting.", vbCritical, "")
	Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisDoc.Document
Dim oRefDocs As DocumentsEnumerator = oADoc.AllReferencedDocuments
For Each oRefDoc As Document In oRefDocs
	'if it is not a Part, skip to next
	If oRefDoc.DocumentType <> DocumentTypeEnum.kPartDocumentObject Then Continue For
	Dim oPDoc As PartDocument = oRefDoc
	'if ModelStates exist, make sure we are working with the 'factory' document
	If oPDoc.ComponentDefinition.IsModelStateMember Then
		oPDoc = oPDoc.ComponentDefinition.FactoryDocument
	End If
	Dim oHFeats As HoleFeatures = oPDoc.ComponentDefinition.Features.HoleFeatures
	If oHFeats.Count = 0 Then Continue For
	For Each oHFeat As HoleFeature In oHFeats
		If Not oHFeat.HoleType = HoleTypeEnum.kCounterSinkHole Then Continue For
		If oHFeat.CSinkAngle.Expression = "90 deg" And _
			oHFeat.CSinkDiameter.Expression = "12 mm" And _
			oHFeat.HoleDiameter.Expression = "7 mm" Then
			oHFeat.HoleDiameter.Expression = "5 mm"
			oHFeat.CSinkDiameter.Expression = "10 mm"
		End If
	Next
	If oPDoc.RequiresUpdate Then oPDoc.Update
	If oPDoc.Dirty Then oPDoc.Save
Next
If oADoc.RequiresUpdate Then oADoc.Update
'If oADoc.Dirty Then oADoc.Save

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

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 5

tobias
Collaborator
Collaborator

Hi @WCrihfield ,

 

Amazing, Thank you so much! Works perfect.

Tobias
The Netherlands
Inventor Pro 2026, Vault Pro 2026, AutoCad Electrical 2026.

If a response answers your question, please use ACCEPT SOLUTION to assist other users later.
0 Likes