Hi @inventor4578. Here is an iLogic rule code example for the task you are trying to do by code. However, in an attempt to work around the issue mentioned by @Stakin I have included some additional code that checks whether or not that 3D Sketch is currently 'consumed' or is owned by a feature, and if so, it makes sure it is set to 'Shared', so that it can be moved around. Hopefully that will work OK, because I do not recall if I ever tried to use it this way before. There is a fairly easy method for moving the 'End of Part' marker up to just before, or just after the 3D Sketch object, but that is not what you wanted, so I just left that line of code commented out for now. The 'End of Part' marker could have likely been found by its name, or another way, but I am doing it the longer way here, just in case its name is language dependent or something like that. Let me know if this works OK for you.
Sub Main
Dim oPDoc As Inventor.PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
If oPDoc Is Nothing Then Return
Dim oS3Ds As Sketches3D = oPDoc.ComponentDefinition.Sketches3D
Dim oS3D As Sketch3D = Nothing
Try : oS3D = oS3Ds.Item("3D Sketch 1") : Catch : End Try
If oS3D Is Nothing Then
Logger.Debug("Specified 3D Sketch Not Found!")
Return
End If
If oS3D.Consumed Or oS3D.IsOwnedByFeature Then
Try : oS3D.Shared = True : Catch : End Try
End If
'oS3D.SetEndOfPart(False)
Dim oModelPane As Inventor.BrowserPane = oPDoc.BrowserPanes.Item("PmDefault")
Dim oS3D_Node As Inventor.BrowserNode = oModelPane.GetBrowserNodeFromObject(oS3D)
Dim oEndOfPart_Node As Inventor.BrowserNode = Nothing
For Each oNode As Inventor.BrowserNode In oModelPane.TopNode.BrowserNodes
Dim oNO As Object = Nothing
Try : oNO = oNode.NativeObject : Catch : End Try
If oNO IsNot Nothing AndAlso TypeOf oNO Is EndOfFeatures Then
oEndOfPart_Node = oNode
Exit For
End If
Next oNode
If oEndOfPart_Node Is Nothing Then
Logger.Debug("The 'End of Part' marker could not be found!")
Return
End If
Try
oModelPane.Reorder(oEndOfPart_Node, True, oS3D_Node)
Catch ex As Exception
Logger.Error("Error reordering BrowserNodes." & vbCrLf & ex.Message)
End Try
End Sub
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)