Adjustments to code which contains all items to one plane

Adjustments to code which contains all items to one plane

will.wells
Explorer Explorer
182 Views
2 Replies
Message 1 of 3

Adjustments to code which contains all items to one plane

will.wells
Explorer
Explorer

Could anyone help with changing this code that contains all items to the XY plane and change it to work plane 1 
@Curtis_Waguespack 

willwells_0-1738848116638.png

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim oPlane As WorkPlane
Dim oProxyPlane As WorkPlaneProxy

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)  

	'check for and skip virtual components
	'(in case a virtual component trips things up)
	If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then		
    	oPlane = oOccurrence.Definition.WorkPlanes.Item(3) 'Work Plane4
		'create component proxy plane in assembly		
   		Call oOccurrence.CreateGeometryProxy(oPlane, oProxyPlane)
	End If
	
	'get assembly plane
	Dim oPlane2 As WorkPlane
	oPlane2 = oAsmCompDef.WorkPlanes.Item(3) 'Work Plane4
	
	' Create the constraint using the work plane proxies.
    Call oAsmCompDef.Constraints.AddFlushConstraint(oProxyPlane, oPlane2, 0)	
Next

Thank you

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

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @will.wells ,

This appears to be a version of this example, which used the work plane collection item number to specify the planes. I'm not sure why I did it that way at the time, but to update this you should be able to provide the plane names as strings in quotes as shown.

Post back if this does not answer the questions.

Hope that helps,

Curtis

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim oPlane As WorkPlane
Dim oProxyPlane As WorkPlaneProxy

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)  

	'check for and skip virtual components
	'(in case a virtual component trips things up)
	If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then		
    	oPlane = oOccurrence.Definition.WorkPlanes.Item("XY Plane") 
		'create component proxy plane in assembly		
   		Call oOccurrence.CreateGeometryProxy(oPlane, oProxyPlane)
	End If
	
	'get assembly plane
	Dim oPlane2 As WorkPlane
	oPlane2 = oAsmCompDef.WorkPlanes.Item("Work Plane1") 
	
	' Create the constraint using the work plane proxies.
    Call oAsmCompDef.Constraints.AddFlushConstraint(oProxyPlane, oPlane2, 0)	
Next

 

In my test I had Work Plane1 in the assembly, and just used the XY plane in the parts 

Curtis_Waguespack_0-1738848770955.png

 

 

EESignature

0 Likes
Message 3 of 3

will.wells
Explorer
Explorer

Very much appreciate the help the solution worked