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?
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?
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 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.
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
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
Thanks, this is appreciated gentleman. I will play with both methods when I get back into work tomorrow and provide an update
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.