iPart constrains with iLogic

iPart constrains with iLogic

Curtis_Waguespack
Consultant Consultant
483 Views
8 Replies
Message 1 of 9

iPart constrains with iLogic

Curtis_Waguespack
Consultant
Consultant

I was helping someone with a configurator and this question came up.

 

Short version:

 

  • iPart member files can not be given named entities
  • named entities in the factory iPart don't derive into the iPart members
  • the iLogic constraints involving iPart members use proxy objects that are specific to the assembly from which they were created, and differ from other assemblies involving the same ipart files

So how do we create iLogic constraints in external rules that can be used in different assemblies, for the same iparts?

 

Long version:

See attached 2022 zip file with examples

 

I have an iPart factory with named Edges as shown

 

Curtis_Waguespack_0-1666728038195.png

 

I use this iPart and place members of it in an assembly, constrain them using the named edges, and then extract the code using Capture Current State as shown here:

Curtis_Waguespack_3-1666728289473.png

 

This is the resulting line of code. It uses Proxy edges rather than the named edges as specified in the ipart Factory

Constraints.AddInsert("Insert:1", "Test100-01:1", "Proxy:Edge0", "Test100-01:2", "Proxy:Edge1", axesOpposed := True)
 

 

This line works fine in the original assembly, or in a derivative of it. But if I use this in an external rule, it does not work in other assemblies using the same ipart files, because the proxy object collection if specific to each assembly, so it generates an error as shown:

 

Curtis_Waguespack_4-1666728510585.png

 

 

 

 

EESignature

484 Views
8 Replies
Replies (8)
Message 2 of 9

A.Acheson
Mentor
Mentor

Thinking outside the box how about imates? They allready function with iparts. Haven't ever used them with ilogic but might be worth investigating. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 9

jun.asai
Explorer
Explorer

I have the same question as Curtis_Waguepack.  In my case, I am using named entities for creating linear dimensions.  I already use iMates for assembling elements.  Can iMate be used in creating Geometry Intent for creating dimension elements in a drawing view?

0 Likes
Message 4 of 9

A.Acheson
Mentor
Mentor

Hi @jun.asai 

In theory it can be used as a reference point but as with all iparts you need to search the factory part to determine the reference geometry. Similar to face entities you can't reference the face directly in the ipart member but instead need to find the face in the factory and then find the face in the member and compare the two. 

 

Can you share an image of what you would like to do? I would guess named entities would be the easiest route.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 5 of 9

jun.asai
Explorer
Explorer
Hello, A.Acheson, Thank you for your response. I have named the face in the factory part. Based on your comment, I need to find the matching (unnamed) face in member part and use that face geometry as the geometry of intent when adding LinearDimensions in VBA. I will take a stab at seeing if there is some pattern in the factory part that can be applied to find the geometry in the member part to identify the face.
0 Likes
Message 6 of 9

A.Acheson
Mentor
Mentor

Hi @jun.asai 

 

Here is the article I used for the bases of the below rule. It explains the face retrieval well. 

https://modthemachine.typepad.com/my_weblog/2020/09/get-named-face-of-ipartfactory.html

 

These two functions here will get you down the road with that. It's a complex process. Further complicating things if you have any extrusion cut of the member part it breaks up the face so see "Function GetModifiedFaceProxy2"

 

 

Function GetCurve(faceName As String,curveIndex As Integer) As DrawingCurve'occ As ComponentOccurrence,,  drawView As DrawingView
	  'https://modthemachine.typepad.com/my_weblog/2020/09/get-named-face-of-ipartfactory.html
	  Dim memberDoc As PartDocument = occ.Definition.Document
	  
	  Dim drawViewCurves As DrawingCurvesEnumerator
	  Dim drawCurve As DrawingCurve = Nothing
	  Dim partFaceProxy As FaceProxy = Nothing
	  Dim namedFace As Object = Nothing
	  If memberDoc.ComponentDefinition.IsiPartMember Then

		  Dim factoryDoc As PartDocument = memberDoc.ComponentDefinition.iPartMember.ReferencedDocumentDescriptor.ReferencedDocument

		  Dim NamedEntities As NamedEntities = iLogicVb.Automation.GetNamedEntities(factoryDoc)
		
		  Try
			namedface = NamedEntities.FindEntity(faceName)
		  Catch
			'Logger.Info("Error getting face entity")
		  End Try
		
		  For Each partFace As Face In memberDoc.ComponentDefinition.SurfaceBodies(1).Faces
			  
			  	If partFace.ReferencedEntity Is namedFace Then
					'Logger.Info("Creation Details " & partFace.ReferencedEntity.CreatedByFeature.Name)
					
						'Logger.Info("Found Face: {0}", faceName)
					Try
						If occ.HasBodyOverride
							partFaceProxy = GetModifiedFaceProxy2(occ, namedFace, partFace)
						Else
							occ.CreateGeometryProxy(partFace, partFaceProxy)
						End If
						
			   			drawViewCurves = drawView.DrawingCurves(partFaceProxy)
			   			'Logger.Info("Drawcurvecount:  " & drawViewCurves.Count)
						For Each curve As DrawingCurve In drawViewCurves
							If Not curveIndex = Nothing Then
								If curve.CurveType = CurveTypeEnum.kLineSegmentCurve Then
									'Logger.Info([Enum].GetName(GetType(Inventor.CurveTypeEnum), curve.CurveType))
									Return drawViewCurves.Item(curveIndex)
									Exit Function
								End If
							Else
								If curve.CurveType = CurveTypeEnum.kLineSegmentCurve Then
									'Logger.Info([Enum].GetName(GetType(Inventor.CurveTypeEnum), curve.CurveType))
									Return curve
									Exit Function
								End If
							End If
						Next
				
					Catch
			    		Logger.Error("Error curve count")
					End Try
				End If
				Try
					 'Face we are looking for has been cut by a feature so will have more than one reference entity, 
					 'so loop through the Collection
					For Each entity As Face In partFace.ReferencedEntity
						'Logger.Info("Checking entity")
						If entity Is namedFace Then 
							'Logger.Info("found entity")
							Try
								If occ.HasBodyOverride Then
									Logger.Info("found entity")
									partFaceProxy = GetModifiedFaceProxy2(occ, namedFace , partFace) 
								Else
									occ.CreateGeometryProxy(partFace, partFaceProxy)
								End If
						   			drawViewCurves = drawView.DrawingCurves(partFaceProxy)
							Catch
					    		Logger.Info("Error curve count")
							End Try
			
							For Each curve As DrawingCurve In drawViewCurves
								If Not curveIndex = Nothing Then
									If curve.CurveType = CurveTypeEnum.kLineSegmentCurve Then
										'Logger.Info([Enum].GetName(GetType(Inventor.CurveTypeEnum), curve.CurveType))
										Return drawViewCurves.Item(curveIndex)
										Exit Function
									End If
								Else
									If curve.CurveType = CurveTypeEnum.kLineSegmentCurve Then
										Logger.Info([Enum].GetName(GetType(Inventor.CurveTypeEnum), curve.CurveType))
										Return curve
										Exit Function
									End If
								End If
								
							Next
						End If
					Next
				Catch
					'Logger.Info("Error")
				End Try
				
				
		Next
		
	  End If
  
End Function



Function GetModifiedFaceProxy2(occ As ComponentOccurrence, namedFace As Face, partFace As Face) As FaceProxy

	For Each occBody As SurfaceBody In occ.SurfaceBodies
		For Each occFace As Face In occBody.Faces
			Dim occSourceFace As Face = occFace.GetSourceFace()
			If occSourceFace Is partFace Then
				Logger.Debug("found")
				Return occFace
			End If
		Next
		Logger.Debug("not found")
		Return Nothing
	Next
End Function

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 9

jun.asai
Explorer
Explorer
Thank you, Alan, this worked well. I was able to get the faces in the iPart to work with the dimension command. I added the new function into a general function to look for named entities. I use that general function for arcs as well so I plan to expand that function further to include arcs.
One other item with iPart: If I add a workpoint in the iPartFactory, it does not show up in the iPart model. I may need to rethink using workpoints and change to using arcs to get the center points.
Message 8 of 9

A.Acheson
Mentor
Mentor

Was the work geometry added to the factory table? If so it show up in the model browser for the member. The only thing we can't control is it's visibility which will leave the member very cluttered. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 9 of 9

jun.asai
Explorer
Explorer
Hello, Alan, thanks for response. No, I had not included the workfeature to the factory table. Once workpoints were added to the factory table, the existing VBA code worked on the ipart member just like a standard ipt file. Works well now. Thanks again.
0 Likes