<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Ilogic - projecting the hole onto the surface instead of standard adaptive in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-projecting-the-hole-onto-the-surface-instead-of-standard/m-p/12219377#M157242</link>
    <description>&lt;P&gt;This is not an answer but topic to discuss.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't understand why you create some non-parametric base features if you want to create planar sketch. You can create sketch directly on part planar face.&lt;/P&gt;&lt;P&gt;Here is more compact sample how to do it. You can select multiple source faces for hole placement.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main()
    Dim asm As AssemblyDocument = ThisDoc.Document
    Dim targetFaceProxy As FaceProxy = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Pick target face or work plane")

    Dim targetOccurrence As ComponentOccurrence = targetFaceProxy.ContainingOccurrence
    Dim targetTransformation As Matrix = targetOccurrence.Transformation
    targetTransformation.Invert()
    Dim targetPartDef As PartComponentDefinition = targetOccurrence.Definition
    Dim targetFace As Face = targetFaceProxy.NativeObject

    Dim holeCenters As New List(Of Point)
    Do
        Dim sourceFace As FaceProxy = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Pick source face or press ESC to continue")
        If sourceFace Is Nothing Then Exit Do
        Dim sourceOccurrence As ComponentOccurrence = sourceFace.ContainingOccurrence
        Dim sourcePartDef As PartComponentDefinition = sourceOccurrence.Definition
        For Each edgeLoop As EdgeLoopProxy In sourceFace.EdgeLoops
            If edgeLoop.IsOuterEdgeLoop Then Continue For
            Dim tempWorkPoint As WorkPoint = sourcePartDef.WorkPoints.AddAtCentroid(edgeLoop.NativeObject, True)
            Dim holeCenterPoint As Point = tempWorkPoint.Point
            tempWorkPoint.Delete()
            holeCenterPoint.TransformBy(sourceOccurrence.Transformation)
            holeCenterPoint.TransformBy(targetTransformation)
            holeCenters.Add(holeCenterPoint)
        Next
    Loop While True

    'Create sketch with center points
    Dim sketch As PlanarSketch = targetPartDef.Sketches.Add(targetFace)

    For Each holeCenter As Point In holeCenters
        Dim holeCenter2d = sketch.ModelToSketchSpace(holeCenter)
        sketch.SketchPoints.Add(holeCenter2d, True)
    Next
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Sep 2023 15:09:45 GMT</pubDate>
    <dc:creator>Michael.Navara</dc:creator>
    <dc:date>2023-09-05T15:09:45Z</dc:date>
    <item>
      <title>Ilogic - projecting the hole onto the surface instead of standard adaptive</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-projecting-the-hole-onto-the-surface-instead-of-standard/m-p/12216583#M157214</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am asking for help in improving my rule that I use to project holes. I use it as in the attached video:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6336569646112w960h540r920" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6336569646112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6336569646112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;	'sprawdzanie czy jesteśmy w złożeniu
If ThisDoc.Document.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kAssemblyDocumentObject Then
		MsgBox("REGULA DZIAŁA TYLKO W ZESPOLE", vbCritical, "OSTRZEŻENIE")
		Exit Sub
End If

Dim oAsm As AssemblyDocument = ThisDoc.Document
Dim oTransaction As Transaction = ThisApplication.TransactionManager.StartTransaction(oAsm, "RZUTOWANIE OTWORÓW")
Dim oFace As FaceProxy
'obsluga bledu jezeli ktoś sie rozmysli przy wybieraniu plaszczyzny z otworami
While True
   oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "WSKAŻ PŁASZCZYZNE Z OTWORAMI")
	' jesli nic nie wybrane to	
	If IsNothing(oFace) Then GoTo koniec Else
		Exit While
End While

Dim oFaceOcc As ComponentOccurrence = oFace.ContainingOccurrence

Dim aFace As FaceProxy

'obsluga bledu jezeli ktoś sie rozmysli przy wybieraniu plaszczyzny rzutowania
While True
   aFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "WSKAŻ PŁASZCZYZNE RZUTOWANIA")
	
	' jesli nic nie wybrane to 	
	If IsNothing(aFace) Then goto koniec Else
		Exit While
End While

Dim aFaceRefKey(-1) As Byte
Dim aFaceKeyContext As Integer = oAsm.ReferenceKeyManager.CreateKeyContext
aFace.GetReferenceKey(aFaceRefKey, aFaceKeyContext)
Dim aOcc As ComponentOccurrence = aFace.ContainingOccurrence
Dim aDef As PartComponentDefinition = aOcc.Definition
Dim NPBFdef As NonParametricBaseFeatureDefinition = aDef.Features.NonParametricBaseFeatures.CreateDefinition
Dim oCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oCol.Add(oFace)
NPBFdef.BRepEntities = oCol
NPBFdef.OutputType = kSurfaceOutputType
NPBFdef.TargetOccurrence = aOcc
NPBFdef.IsAssociative = True

'sprawdzanie czy nie ma użytego pogrubienia lub edycji bezpośredniej
If aDef.Features.ThickenFeatures.Count &amp;gt; 0 Or aDef.Features.DirectEditFeatures.Count &amp;gt;0 Then
	MsgBox("W CZĘŚCI NA KTÓRĄ RZUTUJESZ JEST POGRUBIENIE LUB EDYCJA BEZPOŚREDNIA - USUN TO", vbCritical, "OSTRZEŻENIE")
	goto koniec
	Exit Sub
Else
End If

Dim planeInput As New List(Of KeyValuePair(Of WorkPoint, WorkAxis))

Dim cpySurf As NonParametricBaseFeature
cpySurf = aDef.Features.NonParametricBaseFeatures.AddByDefinition(NPBFdef)
For Each oLoop As EdgeLoop In cpySurf.Faces(1).EdgeLoops
	If oLoop.IsOuterEdgeLoop = False
		Dim oPoint As WorkPoint = aDef.WorkPoints.AddAtCentroid(oLoop)
		Dim oAxis As WorkAxis = aDef.WorkAxes.AddByNormalToSurface(oAsm.ReferenceKeyManager.BindKeyToObject(aFaceRefKey, aFaceKeyContext).NativeObject, oPoint)
		planeInput.Add(New KeyValuePair(Of WorkPoint, WorkAxis)(oPoint, oAxis))
	End If
Next
cpySurf.SurfaceBodies(1).Visible = False


    Dim oPlaszczyzna As WorkPlane = aDef.WorkPlanes.AddByPlaneAndOffset(oAsm.ReferenceKeyManager.BindKeyToObject(aFaceRefKey, aFaceKeyContext).NativeObject, 0)
	oPlaszczyzna.Visible = False
	Dim oSketch As PlanarSketch = aDef.Sketches.Add(oPlaszczyzna)
	oSketch.Visible = True
	
For Each oPair As KeyValuePair(Of WorkPoint, WorkAxis) In planeInput
	Dim oCP As SketchPoint = oSketch.AddByProjectingEntity(oPair.Key)
	Dim oEP As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oCP.Geometry.X + 1 / 2, oCP.Geometry.Y)
	Dim oSlot As SketchEntitiesEnumerator = oSketch.AddStraightSlotBySlotCenter(oCP, oEP, 0.9)
	Dim oLine As SketchLine = oSlot.OfType(Of SketchLine).FirstOrDefault(Function(x As SketchLine) x.Construction = True)
'	oSketch.GeometricConstraints.AddHorizontal(oLine)
	oSketch.DimensionConstraints.AddTwoPointDistance(oLine.StartSketchPoint, oLine.EndSketchPoint, DimensionOrientationEnum.kHorizontalDim, oCP.Geometry)
	Dim oLines = oSlot.OfType(Of SketchLine).Where(Function(x As SketchLine) x.Construction = False)
	Dim oLine1 As SketchLine = oLines(0)
	Dim oLine2 As SketchLine = oLines(1)
	oSketch.DimensionConstraints.AddOffset(oLine1, oLine2, oCP.Geometry, False)
'	Dim oProfile As Profile = oSketch.Profiles.AddForSolid
'	aDef.Features.EmbossFeatures.AddEngraveFromFace(oProfile, 2, PartFeatureExtentDirectionEnum.kNegativeExtentDirection, , oAsm.ReferenceKeyManager.BindKeyToObject(aFaceRefKey, aFaceKeyContext).NativeObject)
	
	oSketch.DimensionsVisible=False
	oPair.Key.Visible = False
	oPair.Value.Visible = False
Next

koniec:
oAsm.Update
oTransaction.End
InventorVb.DocumentUpdate() 

'Wyłaczenie adaptacyjnosci
iLogicVb.Automation.RunExternalRule(oAsm, "ADAPTACJA_OFF")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some ideas for improvement but I don't know how to carry them out.&lt;/P&gt;&lt;P&gt;I would need:&lt;BR /&gt;1. be able to project holes from several planes so that they are in &lt;U&gt;&lt;STRONG&gt;one sketch&lt;/STRONG&gt;&lt;/U&gt; on the projection plane.&lt;BR /&gt;2. measure the projected diameters and on this basis insert the appropriate holes (example: measured diameter = 6.448mm new hole = 9mm)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Someone help me ??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2023 12:29:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-projecting-the-hole-onto-the-surface-instead-of-standard/m-p/12216583#M157214</guid>
      <dc:creator>ralfmja</dc:creator>
      <dc:date>2023-09-04T12:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic - projecting the hole onto the surface instead of standard adaptive</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-projecting-the-hole-onto-the-surface-instead-of-standard/m-p/12219377#M157242</link>
      <description>&lt;P&gt;This is not an answer but topic to discuss.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't understand why you create some non-parametric base features if you want to create planar sketch. You can create sketch directly on part planar face.&lt;/P&gt;&lt;P&gt;Here is more compact sample how to do it. You can select multiple source faces for hole placement.&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main()
    Dim asm As AssemblyDocument = ThisDoc.Document
    Dim targetFaceProxy As FaceProxy = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities, "Pick target face or work plane")

    Dim targetOccurrence As ComponentOccurrence = targetFaceProxy.ContainingOccurrence
    Dim targetTransformation As Matrix = targetOccurrence.Transformation
    targetTransformation.Invert()
    Dim targetPartDef As PartComponentDefinition = targetOccurrence.Definition
    Dim targetFace As Face = targetFaceProxy.NativeObject

    Dim holeCenters As New List(Of Point)
    Do
        Dim sourceFace As FaceProxy = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Pick source face or press ESC to continue")
        If sourceFace Is Nothing Then Exit Do
        Dim sourceOccurrence As ComponentOccurrence = sourceFace.ContainingOccurrence
        Dim sourcePartDef As PartComponentDefinition = sourceOccurrence.Definition
        For Each edgeLoop As EdgeLoopProxy In sourceFace.EdgeLoops
            If edgeLoop.IsOuterEdgeLoop Then Continue For
            Dim tempWorkPoint As WorkPoint = sourcePartDef.WorkPoints.AddAtCentroid(edgeLoop.NativeObject, True)
            Dim holeCenterPoint As Point = tempWorkPoint.Point
            tempWorkPoint.Delete()
            holeCenterPoint.TransformBy(sourceOccurrence.Transformation)
            holeCenterPoint.TransformBy(targetTransformation)
            holeCenters.Add(holeCenterPoint)
        Next
    Loop While True

    'Create sketch with center points
    Dim sketch As PlanarSketch = targetPartDef.Sketches.Add(targetFace)

    For Each holeCenter As Point In holeCenters
        Dim holeCenter2d = sketch.ModelToSketchSpace(holeCenter)
        sketch.SketchPoints.Add(holeCenter2d, True)
    Next
End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 15:09:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-projecting-the-hole-onto-the-surface-instead-of-standard/m-p/12219377#M157242</guid>
      <dc:creator>Michael.Navara</dc:creator>
      <dc:date>2023-09-05T15:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Ilogic - projecting the hole onto the surface instead of standard adaptive</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-projecting-the-hole-onto-the-surface-instead-of-standard/m-p/12219647#M157248</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1104556"&gt;@Michael.Navara&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your interest &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In short, I'm an amateur &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7B4B80143EBEB4F250CEEC82342F6CA1/emoticons/1f609.png" alt=":winking_face:" title=":winking_face:" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'm looking for existing rules, I'm changing them for my ideas due to the fact that I have no experience in programming &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;&lt;P&gt;However, I have a lot of experience in designing and I know what I want to achieve &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;&lt;P&gt;Coming back to your proposal, the effect is in line with my assumptions. However, I need an "action" that will be copied to the solid in which I want to create holes "surfaces" (so that I can enable/disable its adaptivity). Then from this "copied surface" I want to create a sketch and in it (possibly) measure the diameters of the projected circles and insert the appropriate holes &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;&lt;P&gt;Why so?? because (in my opinion) the standard adaptability in inventor causes more problems than good in large assemblies &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;&lt;P&gt;recreating this scheme in the "normal" Inventor operation, I would like to do it as in the video below (of course, I only need to copy surfaces with holes, not the entire solid):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6336629408112w960h540r376" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6336629408112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6336629408112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;To sum up - I want to copy surfaces (one or several which will be adaptive) and create a sketch in a part from it, and then create holes based on this sketch.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you help me achieve this?? &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B4D44A73814D7FC0D950DEDFACB97081/emoticons/1f642.png" alt=":slightly_smiling_face:" title=":slightly_smiling_face:" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 17:15:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-projecting-the-hole-onto-the-surface-instead-of-standard/m-p/12219647#M157248</guid>
      <dc:creator>ralfmja</dc:creator>
      <dc:date>2023-09-05T17:15:54Z</dc:date>
    </item>
  </channel>
</rss>

