iLogic To Create Mirrored Part Feature

iLogic To Create Mirrored Part Feature

felix.cortes5K3Y2
Advocate Advocate
1,229 Views
5 Replies
Message 1 of 6

iLogic To Create Mirrored Part Feature

felix.cortes5K3Y2
Advocate
Advocate

Hi Forum,

 

I am trying to create a mirrored feature of another feature using iLogic. Here's what I've written and I am not sure why it is not being executed

 

Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oPDC As Inventor.PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oFeatures As Inventor.PartFeatures = oPDC.Features
Dim oExtrude As Inventor.PartFeature = oFeatures("Extrude1") 
Dim oPlane As Inventor.WorkPlane = oPDC.WorkPlanes.Item("Work Plane2") 
Dim oBjColSweep As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim oBjColPlane As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oBjColExtrude.Add(oExtrude) 
oBjColPlane.Add(oPlane) 

Dim oMirs As Inventor.MirrorFeatures = oFeatures.MirrorFeatures
Dim oMirFeatDef As Inventor.MirrorFeatureDefinition
	oMirFeatDef = oFeatures.MirrorFeatures.CreateDefinition(oBjColExtrude, oBjColPlane) 
Dim oMirFeat As Inventor.MirrorFeature 
	oMirFeat = oMirs.AddByDefinition(oMirFeatDef) 
oMirFeat.Name = "Testing"
	

 

Best regards,

Felix

 

0 Likes
1,230 Views
5 Replies
Replies (5)
Message 2 of 6

Sergio.D.Suárez
Mentor
Mentor

Hi, try the following ilogic rule. The workplane must be loaded into the definition as an object not as a collection.

Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oPDC As Inventor.PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oFeatures As Inventor.PartFeatures = oPDC.Features
Dim oExtrude As Inventor.PartFeature = oFeatures("Extrude1") 
Dim oBjPlane As Object = oPDC.WorkPlanes.Item("Work Plane2") 
Dim oBjColExtrude As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
'Dim oBjColSweep As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oBjColExtrude.Add(oExtrude) 

Dim oMirs As Inventor.MirrorFeatures = oFeatures.MirrorFeatures
Dim oMirFeatDef As Inventor.MirrorFeatureDefinition
	oMirFeatDef = oFeatures.MirrorFeatures.CreateDefinition(oBjColExtrude, oBjPlane)

Dim oMirFeat As Inventor.MirrorFeature 
	oMirFeat = oMirs.AddByDefinition(oMirFeatDef) 
oMirFeat.Name = "Testing"

I hope this helps with your work. regards


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
Message 3 of 6

Is there a way to modify you code a bit , to make an mirror , that make an new solid body and Remove original ? and if it run again , delete the mirror and redo the process ?

 

 

Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oPDC As Inventor.PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oFeatures As Inventor.PartFeatures = oPDC.Features
Dim oExtrude As Inventor.PartFeature = oFeatures("Extrusion1") 
Dim oExtrude2 As Inventor.PartFeature = oFeatures("Extrusion2") 
Dim oBjPlane As Object = oPDC.WorkPlanes.Item("Work Plane1") 
Dim oBjColExtrude As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
'Dim oBjColSweep As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oBjColExtrude.Add(oExtrude) 
oBjColExtrude.Add(oExtrude2)

Dim oMirs As Inventor.MirrorFeatures = oFeatures.MirrorFeatures
Dim oMirFeatDef As Inventor.MirrorFeatureDefinition
	oMirFeatDef = oFeatures.MirrorFeatures.CreateDefinition(oBjColExtrude, oBjPlane)

Dim oMirFeat As Inventor.MirrorFeature 

	oMirFeat = oMirs.AddByDefinition(oMirFeatDef)
	'oMirs.NewBodyOperation = True
oMirFeat.Name = "Testing"

 

0 Likes
Message 4 of 6

Ralf_Krieg
Advisor
Advisor

Hello

 

To create a new body and remove the original use these lines. If you run again how do you identify the original mirror feature? There can be more than one. And why want you delete and run again? With the code above, it will result in exact the same.

 

oMirFeatDef.Operation = PartFeatureOperationEnum.kNewBodyOperation
oMirFeatDef.RemoveOriginal=-True

 

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 5 of 6

Darkforce_the_ilogic_guy
Advisor
Advisor
I want to run it again because I want to be able to change witch feature I add to the mirror

And because I might one time need the mirror and sometime not. This is for an Factory assets... I might need an mirror version and/or need all or only some of the part in the mirror.

I need the color and flexibility to make as many config as possible

0 Likes
Message 6 of 6

Ralf_Krieg
Advisor
Advisor

Hello

 

If you delete and recreate it, all following features with a reference to a face, edge or sufacebody created or modified by this feature will fail, cause the internal ID's will change. Probably the same will happen if you edit the feture.

Anyway, I've played around a bit with editing the mirror feature. I expected that replacing the MirrorFeatureDefinition with a modified one would do. With a feature mirror (e.g. mirror an extrusion) it works. Doing the same with a solid body mirror, as you asked for, fails in any way I tried. Maybe someone else can help me out.

As an alternative, is it possible that you create all variations and suppress the currently not needed? The suppression could simpliest directed by an user defined fx-parameter. Setting the parameter up as an multivalue list, you could the parameter integrate as radio button group in an iLogic formular.


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes