Create hole in content center pipe in an assembly

Create hole in content center pipe in an assembly

jroyse
Participant Participant
384 Views
3 Replies
Message 1 of 4

Create hole in content center pipe in an assembly

jroyse
Participant
Participant

I am new to ilogic. I have gotten my code to place and change the size of pipe from Content Center. I now need to add a hole through the side of the pipe depending on what the user selects in the form. Is it possible to start a sketch and add a hole with ilogic? Thanks

0 Likes
Accepted solutions (1)
385 Views
3 Replies
Replies (3)
Message 2 of 4

theo.bot
Collaborator
Collaborator

@jroyse ,

 

Yes you can, but there are no standard ilogic snippets for that. Meaning you have to use the Inventor API to create your code. Take a look at the API help to find more info and samples: Inventor 2023 Help | Sketches | Autodesk 
Inventor 2023 Help | Hole Feature - Through holes (RegularAndTapped) | Autodesk

0 Likes
Message 3 of 4

A.Acheson
Mentor
Mentor
Accepted solution

Here is a sample , I have left in some comments so you can see how it is working. It gets rather complicated quickly with the need for proxies etc. 

Approx Layout:

1. Occurence
2. PartDef
3. ProxyWorkPlane (Part)

4. AssemblySketch
5. SketchPoint(HoleCenter)
6. SketchHolePlacementDefinition
6. HoleFeature

 

Dim oAssyDef As AssemblyComponentDefinition = ThisDoc.Document.ComponentDefinition
	
	Dim oCommandMgr As CommandManager = ThisApplication.CommandManager
	
    Dim oOcc As ComponentOccurrence = oCommandMgr.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Part Occurrence")
	
	MessageBox.Show(oOcc.Name, "Occurrence Name")
	
	Dim oPartDef As PartComponentDefinition = oOcc.Definition
   
	' Select the plane we want to work with
	Dim oWPlane1 As WorkPlane = oPartDef.WorkPlanes.Item("XZ PLANE") 
	
	' Need a proxy to identify where the workplane is located in assembly space. 
    Dim oWPlane1Proxy As WorkPlaneProxy
	oOcc.CreateGeometryProxy(oWPlane1, oWPlane1Proxy)
	'Dim oWorkPlaneProxy As WorkPlaneProxy = oCommandMgr.Pick(SelectionFilterEnum.kWorkPlaneFilter, "Select Part Workplane")
	
	' Create a new sketch on the work plane proxy.
	Dim oSketch As PlanarSketch = oAssyDef.Sketches.Add(oWPlane1Proxy)
    'Dim oSketch As PlanarSketch = oCommandMgr.Pick(SelectionFilterEnum.kSketchObjectFilter, "Select Part Sketch")            
     
	' Create a new object collection for the hole center points.
    oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection
   
	Dim oPoint As Point = oPartDef.WorkPoints("Center Point").Point
	
	' Set a reference to the transient geometry object.
	Dim oTransGeom As TransientGeometry = ThisApplication.TransientGeometry
	
	' Add a point as hole center.
    oHoleCenters.Add (oSketch.SketchPoints.Add(oTransGeom.CreatePoint2d(oPoint.X-1, oPoint.Y)))
   'oHoleCenters.Add(oSketch.SketchPoints(1))' Add from existing sketch
  	
	Dim oHoleFeatures As HoleFeatures = oAssyDef.Features.HoleFeatures
  
 	Dim oSketchHolePlacementDef As SketchHolePlacementDefinition = oHoleFeatures.CreateSketchPlacementDefinition(oHoleCenters)
  
  	Dim oHoleFeature As HoleFeature = oHoleFeatures.AddDrilledByThroughAllExtent(oSketchHolePlacementDef, 0.8, kNegativeExtentDirection)
  

 

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

jroyse
Participant
Participant

@A.Acheson  that worked great! After a few tweaks it's doing what I need it to. Thank you!

0 Likes