adaptive workpoint assembly -> redefine with geometry from another part

adaptive workpoint assembly -> redefine with geometry from another part

Sergio.D.Suárez
Mentor Mentor
468 Views
1 Reply
Message 1 of 2

adaptive workpoint assembly -> redefine with geometry from another part

Sergio.D.Suárez
Mentor
Mentor

Hi, I have a question that I have not been able to solve. I have two pieces inside an assembly. I would like with an Ilogic rule, from the assembly to select a workpoint from the part (Adaptative), define it as adaptive, and then redefine it with a vertex of the geometry of another part (Base). I need to solve this simple task and then apply it to a more complex problem, where several points of arbitrary orientation define the main geometries of my assembly.
I tried to make a code, which did not work for me.

 

Sub Main()
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oPart As ComponentOccurrence

'Pick part occurrence
oPart = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Seleccione Pieza")
	If oPart Is Nothing Then
		Exit Sub
	Else
		oPart.Adaptive = True
		Dim oDef As PartComponentDefinition
	    oDef = oPart.Definition

Dim MidA As WorkPoint = oDef.WorkPoints.Item("Med1") 
MidA.Adaptive = True
overt = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartVertexFilter, "Seleccione Vertice")
	
MidA.SetByPoint(overt)
	End If
End Sub

Adaptative workpoint.jpg

Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Accepted solutions (1)
469 Views
1 Reply
Reply (1)
Message 2 of 2

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Trying to follow another way, I have managed to develop this code, which has solved the problem. If a similar problem occurs to someone, it may be useful

 

Sub Main()
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oPart As ComponentOccurrence

'Pick part occurrence
oPart = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Seleccione Pieza")
	If oPart Is Nothing Then
		Exit Sub
	Else
		oPart.Adaptive = True
		oPart.Edit
		Dim oDef As PartComponentDefinition
	        oDef = oPart.Definition

		Dim oMed1 As WorkPoint
		oMed1 = oDef.WorkPoints.Item("Med1")

		Dim oCommand As CommandManager
		oCommand = ThisApplication.CommandManager

		oCommand.DoSelect(oMed1)'Select workpoint

		Dim oControlDef As ControlDefinition ' Get control definition for the line command. 
		oControlDef = oCommand.ControlDefinitions.Item("RedefineFeatureWrapperCmd")  

		oControlDef.Execute2(True)  ' Execute the command. 
		
		oPart.ExitEdit(63746) 'kExitToParent 
				
	End If
End Sub

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes