Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Method of Identifying Face Name That a Hole Feature Is On

3 REPLIES 3
Reply
Message 1 of 4
sean.boyle77X79
158 Views, 3 Replies

iLogic Method of Identifying Face Name That a Hole Feature Is On

sean.boyle77X79
Contributor
Contributor

Hello, I'm currently writing some code for an automatic DXF rule, and I'm running into issues with countersunk holes, as the DXF should display the smaller "though" hole, not the open countersunk end.

 

My question is, how can use utilise the code to identify the entity face name that the countersunk hole has been modelled on? The idea is that if it's been modelled on "Face0", that's where the larger hole will be so the DXF will be taken from the opposite face "Face1" for example.

 

Does someone have a snippet of code which can identify this?

0 Likes

iLogic Method of Identifying Face Name That a Hole Feature Is On

Hello, I'm currently writing some code for an automatic DXF rule, and I'm running into issues with countersunk holes, as the DXF should display the smaller "though" hole, not the open countersunk end.

 

My question is, how can use utilise the code to identify the entity face name that the countersunk hole has been modelled on? The idea is that if it's been modelled on "Face0", that's where the larger hole will be so the DXF will be taken from the opposite face "Face1" for example.

 

Does someone have a snippet of code which can identify this?

3 REPLIES 3
Message 2 of 4
A.Acheson
in reply to: sean.boyle77X79

A.Acheson
Mentor
Mentor

Hi @sean.boyle77X79 

If you have a look at this VBA sample here you will see that you can look at the start faces.

 

Another approach and maybe slightly easier is to get the sketch that made the hole and check it's parent which will be a planar Face in your situation but could also be a workplane. Haven't tested this mind you so let us know if you run into issues.

Syntax

HoleFeature.Sketch() As PlanarSketch

Syntax

PlanarSketch.Parent() As Object

 

I would suggest to pair this with some highlighting code so you can test your outcomes. See forum post here that Wesley put together which is handy. 

 

 

 

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

Hi @sean.boyle77X79 

If you have a look at this VBA sample here you will see that you can look at the start faces.

 

Another approach and maybe slightly easier is to get the sketch that made the hole and check it's parent which will be a planar Face in your situation but could also be a workplane. Haven't tested this mind you so let us know if you run into issues.

Syntax

HoleFeature.Sketch() As PlanarSketch

Syntax

PlanarSketch.Parent() As Object

 

I would suggest to pair this with some highlighting code so you can test your outcomes. See forum post here that Wesley put together which is handy. 

 

 

 

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

Curtis_Waguespack
Consultant
Consultant

Hi @sean.boyle77X79 

 

Not sure if this will help in your case, but when I've done this sort of thing in the past, I've just set the holes to be simple thru holes and then set them back to counterbore, countersinks, etc. after the DXF out.

 

Here's a simple example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oHole As HoleFeature
oHole = ThisDoc.Document.ComponentDefinition.Features.Item("Hole1")

Dim oCBoreDepth As String
Dim oCBoreDiameter As String
Dim oList As New ArrayList

For Each oHole In ThisDoc.Document.ComponentDefinition.Features.holefeatures

	If oHole.HoleType = HoleTypeEnum.kCounterBoreHole Then
		'get counterbore info
		oCBoreDiameter = oHole.CBoreDiameter.Value * 0.39370079 'converts value from cm to inch
		oCBoreDepth = oHole.CBoreDepth.Value * 0.39370079 'converts value from cm to inch

		'assemble info using vertical bar as separator
		oList.Add(oHole.Name & "|" & oCBoreDiameter & "|" & oCBoreDepth)

		'set to simple drilled hole
		oHole.SetDrilled
	End If

Next

MsgBox("your DXF export code here",,"iLogic")

For Each oHole In ThisDoc.Document.ComponentDefinition.Features.holefeatures
	
	For Each oHoleInfo In oList
		oStrings = Split(oHoleInfo, "|") 'split value using vertical bar
		
		sHoleName = oStrings(0)
		oCBoreDiameter = oStrings(1)
		oCBoreDepth = oStrings(2)

		If sHoleName = oHole.Name Then
			'set back to counter bore
			oHole.SetCBore(oCBoreDiameter, oCBoreDepth)
		End If
	Next
Next

 

0 Likes

Hi @sean.boyle77X79 

 

Not sure if this will help in your case, but when I've done this sort of thing in the past, I've just set the holes to be simple thru holes and then set them back to counterbore, countersinks, etc. after the DXF out.

 

Here's a simple example.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oHole As HoleFeature
oHole = ThisDoc.Document.ComponentDefinition.Features.Item("Hole1")

Dim oCBoreDepth As String
Dim oCBoreDiameter As String
Dim oList As New ArrayList

For Each oHole In ThisDoc.Document.ComponentDefinition.Features.holefeatures

	If oHole.HoleType = HoleTypeEnum.kCounterBoreHole Then
		'get counterbore info
		oCBoreDiameter = oHole.CBoreDiameter.Value * 0.39370079 'converts value from cm to inch
		oCBoreDepth = oHole.CBoreDepth.Value * 0.39370079 'converts value from cm to inch

		'assemble info using vertical bar as separator
		oList.Add(oHole.Name & "|" & oCBoreDiameter & "|" & oCBoreDepth)

		'set to simple drilled hole
		oHole.SetDrilled
	End If

Next

MsgBox("your DXF export code here",,"iLogic")

For Each oHole In ThisDoc.Document.ComponentDefinition.Features.holefeatures
	
	For Each oHoleInfo In oList
		oStrings = Split(oHoleInfo, "|") 'split value using vertical bar
		
		sHoleName = oStrings(0)
		oCBoreDiameter = oStrings(1)
		oCBoreDepth = oStrings(2)

		If sHoleName = oHole.Name Then
			'set back to counter bore
			oHole.SetCBore(oCBoreDiameter, oCBoreDepth)
		End If
	Next
Next

 

Message 4 of 4

sean.boyle77X79
Contributor
Contributor

Thanks, this is appreciated gentleman. I will play with both methods when I get back into work tomorrow and provide an update

0 Likes

Thanks, this is appreciated gentleman. I will play with both methods when I get back into work tomorrow and provide an update

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report