07-03-2018
11:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
07-03-2018
11:46 AM
I think this might give you what you need. I quickly prototyped it in VBA but it can easily be converted to be VB.NET compatible, which is what iLogic uses.
Public Sub AutoProject()
' a reference to the currently active document.
' This assumes that it is a part document.
Dim oPart As PartDocument
Set oPart = ThisApplication.ActiveDocument
' a reference to the component definition.
Dim oDef As PartComponentDefinition
Set oDef = oPart.ComponentDefinition
Dim planeEnt As Object
Set planeEnt = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Select plane to create the sketch.")
Dim oSketch As PlanarSketch
Set oSketch = oDef.Sketches.Add(planeEnt)
Dim sketchName As String
sketchName = InputBox("Give your new sketch a name", "Sketch Name", "Enter Sketch Name Here")
oSketch.name = sketchName
Dim feat As PartFeature
Set feat = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFeatureFilter, "Select the feature to project")
' Iterate over the faces that were created by the feature.
Dim usedEdges As ObjectCollection
Set usedEdges = ThisApplication.TransientObjects.CreateObjectCollection
Dim featFace As Face
For Each featFace In feat.faces
' Iterate over the edges in the faces.
Dim featEdge As Edge
For Each featEdge In featFace.Edges
' Check to see if this edge has already been projected.
Dim checkEdge As Edge
Dim isUsed As Boolean
isUsed = False
For Each checkEdge In usedEdges
If featEdge Is checkEdge Then
isUsed = True
Exit For
End If
Next
If Not isUsed Then
' Project the edge onto the sketch.
Call oSketch.AddByProjectingEntity(featEdge)
' Add this edge to the list of used edges.
Call usedEdges.Add(featEdge)
End If
Next
Next
End Sub
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com