Need help with strange problem with copy surface between parts

Need help with strange problem with copy surface between parts

rikard.nilsson
Collaborator Collaborator
644 Views
7 Replies
Message 1 of 8

Need help with strange problem with copy surface between parts

rikard.nilsson
Collaborator
Collaborator

Hi,

 

I have a very strange problem that I need some help with..

I have attached an assembly with a simple structure.

 

What my iLogic rule is trynig to do is to copy  surfaces that is placed inside CenterPlate-occurrences to 2 different parts in CenterPipe-assy.

 

        CompOccNames.add("CentralPipe.CentralPipe_1")
        CompOccNames.add("CentralPipe.CentralPipe_2")

The strange thing is that the placement of the surfaces always will be placed right in the first part that is added in the list above.. If I change the order to

 

CompOccNames.add("CentralPipe.CentralPipe_2")
CompOccNames.add("CentralPipe.CentralPipe_1")

 Then the CentralPipe_2 will have their surfaces in the right position and not CentralPipe_1

 

I do understand that it has to be something ith the Matrix..

But I can't see why.. Because the rows below should reset the matrix..

 

Dim oMatrix2 As Matrix
oMatrix2 = PipeOcc.Transformation

 

Is there anyone that can help me solve my problem?

I'm using Inventor 2017

 

Best Regards

Rikard

0 Likes
Accepted solutions (1)
645 Views
7 Replies
Replies (7)
Message 2 of 8

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @rikard.nilsson,

 

Downloaded the attachment and opened in Inventor 2017.

 

Successfully executed rule called "SculptTest" available at TestSculpt.iam file.

 

As you mentioned in the post, "CompOccNames" list are interchanged. unable to identify differences in assembly file.

 

Can you please provide screenshot of differences in Assembly file?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 8

rikard.nilsson
Collaborator
Collaborator

Hi,

 

I have attached a picture where I'm trying to show you the problem.

 

This is my order

 

CompOccNames.add("CentralPipe.CentralPipe_1")
CompOccNames.add("CentralPipe.CentralPipe_2")

To the left I show you the part of CentralPipe_1. There you see that my surfaces are placed in the right position and created the sculpt as it should.

To the right you can see the surfaces placed in the worong position and give error on sculpt..

 

And if I change the order then CentralPipe_1 will have the error..

 

/Rikard

0 Likes
Message 4 of 8

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @rikard.nilsson,

 

Fortunately, all copied surfaces positioned properly even after interchanging "CompOccNames" list.

 

For more details, go through the following screencast.

 

Thanks and regards,

CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 8

rikard.nilsson
Collaborator
Collaborator

Hi,

 

Sorry.. I don't understand.

 

Is the sculpt feature working in both the parts when you do it?

You did not show that in your screen cast. 

 

Sculpt2.JPG

0 Likes
Message 6 of 8

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi @rikard.nilsson,

 

Try the following changes in iLogic code.

 

Class ThisRule
	Sub Main()

	Dim CutSurfacePartRefChainList As New List(Of String)
	Dim CompOccNames As New List(Of String)

		For i=1 To 19
			CutSurfacePartRefChainList.add("SubAssy.StairStep_" & i & ".CenterPlate")
		Next

'		CompOccNames.add("CentralPipe.CentralPipe_2")
		CompOccNames.add("CentralPipe.CentralPipe_1")
		'CompOccNames.add("CentralPipe.CentralPipe_2")

	CreateSculptFeature("CutSurface", CutSurfacePartRefChainList, CompOccNames, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
	CompOccNames.Clear()
	CompOccNames.add("CentralPipe.CentralPipe_2")
	CreateSculptFeature("CutSurface", CutSurfacePartRefChainList, CompOccNames, PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
   iLogicVb.UpdateWhenDone = True
	End Sub
	
	
	Function CreateSculptFeature(CutSurfaceName As String, CutSurfacePartRefChainList As List(Of String), CompOccNames as List(Of String), SurfaceDirection As PartFeatureExtentDirectionEnum)
			
			Dim oAssemblyDoc As AssemblyDocument = ThisServer.ActiveDocument
			Dim oAssemblyDef As AssemblyComponentDefinition = oAssemblyDoc.ComponentDefinition
			Dim oSurfaces As ObjectCollection= ThisServer.TransientObjects.CreateObjectCollection
			
			Dim oSurfaceBodies As New List(Of Inventor.SurfaceBody)
	
			Dim oMatrixes As ObjectCollection= ThisServer.TransientObjects.CreateObjectCollection
			
			For Each refchain in CutSurfacePartRefChainList
				Dim iPath() As String = refchain.split(".")
				Dim arr As New ArrayList 
				arr.add(iPath(0))
				arr.add(iPath(1))
				arr.add(iPath(2))
				OccWithSurface  = Component.InventorComponentInThisContext(arr)
				Dim OccWithSurfacePartDef As PartComponentDefinition = OccWithSurface.Definition
				For Each item in  OccWithSurfacePartDef.Worksurfaces
					If item.Surfacebodies(1).CreatedByFeature.Name = CutSurfaceName Then
						Dim oSourceBody As SurfaceBody = item.Surfacebodies(1)
						oSurfaceBodies.add(oSourceBody)
						oMatrixes.add(OccWithSurface.Transformation)
						Exit For
					End If
				Next
			Next
					
					
			For i= 0 To CompOccNames.Count-1
				Dim occPath() As String = CompOccNames(i).split(".")
				Dim occarr As New ArrayList 
				occarr.add(occPath(0))
				occarr.add(occPath(1))
					Dim PipeOcc As ComponentOccurrence = Component.InventorComponentInThisContext(occarr)
					Dim PipeOccDef As PartComponentDefinition = PipeOcc.Definition

					Dim oMatrix2 As Matrix
					oMatrix2 = PipeOcc.Transformation
					oMatrix2.Invert
					  
					oSurfaces.clear()
					
					For ii= 0 To oSurfaceBodies.count -1
						Dim oMatrix1 As Matrix = oMatrixes(ii+1)
						oMatrix1.PreMultiplyBy(oMatrix2)
						PipeOccDef.Features.NonParametricBaseFeatures.Add(oSurfaceBodies(ii), oMatrix1)
						oSurfaces.Add(PipeOccDef.Features.SculptFeatures.CreateSculptSurface(PipeOccDef.WorkSurfaces.Item(PipeOccDef.WorkSurfaces.count), _
																								SurfaceDirection))
					Next

					PipeOccDef.Features.SculptFeatures.Add(oSurfaces, PartFeatureOperationEnum.kCutOperation )
			Next
			
					




	End Function
End Class

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 7 of 8

rikard.nilsson
Collaborator
Collaborator

Hi @chandra.shekar.g

 

Thank you soo much!!!

But I wonder if you have any idea why it works when you do it your way and not in my way?

 

/Rikard

0 Likes
Message 8 of 8

chandra.shekar.g
Autodesk Support
Autodesk Support

Hi @rikard.nilsson,

 

I suspect that transformation matrix values are carrying forward in your case.

 

That's why, I am calling CompOccNames individually.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes