Not Implemented? Works in all but one part at random?

Not Implemented? Works in all but one part at random?

J_Pfeifer_
Advocate Advocate
131 Views
1 Reply
Message 1 of 2

Not Implemented? Works in all but one part at random?

J_Pfeifer_
Advocate
Advocate

Hello guys, 

 

 

I'm getting this "not implemented" error on a piece of code I've copied across many of my parts. The function is the same between them all, with different targeting methods depending on the template part. The line that's erroring is the i = oSketch.Dependants.count.

 

The following code is the base that all were copied from:

Sub main()
	
	Dim oDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
	
	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
	Dim oTO As TransientObjects = ThisApplication.TransientObjects
	
	Dim WPC As Integer = 1
	Dim PSC As Integer = 1
	Dim LoopCount As Integer
	Dim LoopIndex As Integer
	
	For Each oWorkPlane As WorkPlane In oCompDef.WorkPlanes
		If oWorkPlane.IsCoordinateSystemElement = True Then 
		
		Else
			WPC = WPC + 1
		End If 
	Next
	
	PSC = oCompDef.Sketches.Count
	
	Logger.Info("WorkPlane count: " & WPC & " planar sketch count: " & PSC)
	
	LoopCount = Math.Max(PSC, WPC)
	
	Logger.Info("Loop count: " & LoopCount)
	
'This entire function/rule was placed into a loop where we check the total number of needed sketches or objects without dependents. This takes care of sketches without features on floating planes, because the rule then runs again
'Destroying the same planes that just held the sketches at deletion from the last. 
While LoopIndex < LoopCount 
	
	For Each oWorkplane As WorkPlane In oCompDef.WorkPlanes
		If oWorkplane.IsCoordinateSystemElement = True Then
			
		Else
			i = oWorkplane.Dependents.Count
			
			If i = 0 Then 
				oWorkplane.Delete
			End If 
		End If 
	Next
	
	For Each osketch As PlanarSketch In oCompDef.Sketches
		
		i = osketch.Dependents.Count
		
		If i = 0 Then
			osketch.Delete
		End If 
	Next
	
	LoopIndex = LoopIndex + 1
	
End While
	
MessageBox.Show("Sketch and plane purge complete")
	
End Sub

 

Then the follow code here is the small changes that are erroring: 

Sub main()
	
	Dim oDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
	
	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
	Dim oTO As TransientObjects = ThisApplication.TransientObjects
	
	Dim WPC As Integer = 1
	Dim PSC As Integer = 1
	Dim LoopCount As Integer
	Dim LoopIndex As Integer
	
	For Each oWorkPlane As WorkPlane In oCompDef.WorkPlanes
		If oWorkPlane.IsCoordinateSystemElement = True Then
			'nothing - this checks if the plane object found is a origin plane. If it is not it adds a number to the list. 
		Else
			WPC = WPC + 1
		End If 
	Next
	
	PSC = oCompDef.Sketches.Count
	
	Logger.Info("WorkPlane count: " & WPC & " planar sketch count: " & PSC)
	
	LoopCount = Math.Max(PSC, WPC)
	
	Logger.Info("Loop count: " & LoopCount)
	
'This entire function/rule was placed into a loop where we check the total number of needed sketches or objects without dependents. This takes care of sketches without features on floating planes, because the rule then runs again
'Destroying the same planes that just held the sketches at deletion from the last. 
While LoopIndex < LoopCount 
	
	For Each oWorkplane As WorkPlane In oCompDef.WorkPlanes
		If oWorkplane.IsCoordinateSystemElement = True Then
			
		Else
			i = oWorkplane.Dependents.Count
			
			If i = 0 Then 
				oWorkplane.Delete
			End If 
		End If 
	Next
	
	For Each osketch As PlanarSketch In oCompDef.Sketches
		If osketch IsNot Nothing Then
			i = osketch.Dependents.Count '<--- ERRORS HERE
			If i = 0 And osketch.Name IsNot "Programming Reference - Do not delete" Then
				osketch.Delete
			End If 
		End If
	Next
	
	LoopIndex = LoopIndex + 1
	
End While
	
MessageBox.Show("Sketch and plane purge complete")
	
End Sub

 

what would be creating this behavior? Not encountered this error, nor does copying the working version into the rule have any effect. 

 

0 Likes
132 Views
1 Reply
Reply (1)
Message 2 of 2

J_Pfeifer_
Advocate
Advocate

I was able to get the sketch and planes to remove from the model browser as intended. 

 

Not exactly sure what was creating this issue. I suspect the planar sketch object and sketch object have differences in dependents? 

 

If anyone has anymore insight into the error I'd appreciated it. 

0 Likes