Move 3D Sketch at the end of model

Move 3D Sketch at the end of model

inventor4578
Advocate Advocate
292 Views
3 Replies
Message 1 of 4

Move 3D Sketch at the end of model

inventor4578
Advocate
Advocate

Hi, i would like to know if iLogic exist to move a specific Sketch (3D Sketch 1) just before the "End Of Part". Because i use the Copy Object technic, and i would like to keep the 3D sketch always at the end.

 

If possible, i will put into Even Triggers

 

inventor4578_0-1719301142094.png

 

Thank you very much

 

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

Stakin
Collaborator
Collaborator

The prerequisite for moving the 3D sketch to the end is that the subsequent features have never used it.

0 Likes
Message 3 of 4

WCrihfield
Mentor
Mentor
Accepted solution

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

EESignature

(Not an Autodesk Employee)

Message 4 of 4

inventor4578
Advocate
Advocate

EXCELLENT. Working good ! Thank you very much.

0 Likes