iLogic Rectangular Pattern

iLogic Rectangular Pattern

Cosmin_V
Advocate Advocate
392 Views
3 Replies
Message 1 of 4

iLogic Rectangular Pattern

Cosmin_V
Advocate
Advocate

Hello everyone,


I have a part with a hole. And I would like to pattern the hole via iLogic in YZ Plane.

I manage to do it in XZ Plane, but in YZ Plane it make it but with an error.

Cosmin_V_0-1664793775773.png

Can someone help me?

 

Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oPartComp As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oHole As HoleFeature = oPartComp.Features.HoleFeatures.Item(1)
Dim oBjCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Call oBjCol.Add(oHole)
    Dim oPlane As WorkPlane
    oPlane = oPartDoc.ComponentDefinition.WorkPlanes(2)
oRectFeat = oPartComp.Features.RectangularPatternFeatures.Add(oBjCol, oPlane, true, 2, 3, PatternSpacingTypeEnum.kDefault)
0 Likes
Accepted solutions (1)
393 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Hi @Cosmin_V.  I'm not sure which version of Inventor you are using, but I am using 2022.3.1, and in this version, you are directed to make a feature definition first, then make the actual feature using that definition, like the example below.  This worked just fine for me.

 

Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oPartComp As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oFeats As PartFeatures = oPartComp.Features
Dim oHole As HoleFeature = oFeats.HoleFeatures.Item(1)
Dim oBjCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oBjCol.Add(oHole)
Dim oXAxis As WorkAxis = oPartComp.WorkAxes.Item("X Axis")
Dim oRectFeatDef As RectangularPatternFeatureDefinition
oRectFeatDef = oFeats.RectangularPatternFeatures.CreateDefinition(oBjCol, oXAxis, True, 2, 3, PatternSpacingTypeEnum.kDefault)
Dim oRectFeat As RectangularPatternFeature
oRectFeat = oFeats.RectangularPatternFeatures.AddByDefinition(oRectFeatDef)

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

Cosmin_V
Advocate
Advocate

thanks @WCrihfield 

 

I use the same version of inventor as you do!

Now i have another problem, I try to do a mirror of a hole, but something it dose not work

Here it is my code...

 

Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oPartComp As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oFeats As PartFeatures = oPartComp.Features
Dim oHole As HoleFeature = oFeats.HoleFeatures.Item(1)
Dim oBjCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oBjCol.Add(oHole)
Dim oXaxis As WorkAxis = oPartComp.WorkAxes.Item("X Axis")
Dim oMirs As Inventor.MirrorFeatures = oFeats.MirrorFeatures
Dim oMirFeatDef As Inventor.MirrorFeatureDefinition
	oMirFeatDef = oFeats.MirrorFeatures.CreateDefinition(oBjCol, oXaxis)

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

 

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Hi @Cosmin_V.  Sorry for the delayed response.  Lots of stuff going on.  I think I fixed your code.  First of all the mirror feature was looking for a 'planar' object, which a WorkPlane is ideal for, not a WorkAxis.  Then, for some reason, I had to specify the third, optional input to the CreateDefinition method, so that it would work correctly.

Dim oPartDoc As PartDocument = ThisDoc.Document
Dim oPartComp As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oFeats As PartFeatures = oPartComp.Features
Dim oHole As HoleFeature = oFeats.HoleFeatures.Item(1)
Dim oBjCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oBjCol.Add(oHole)
Dim oYZPlane As WorkPlane = oPartComp.WorkPlanes.Item("YZ Plane")
Dim oMirs As Inventor.MirrorFeatures = oFeats.MirrorFeatures
Dim oMirFeatDef As Inventor.MirrorFeatureDefinition
	oMirFeatDef = oMirs.CreateDefinition(oBjCol, oYZPlane, PatternComputeTypeEnum.kAdjustToModelCompute)
Dim oMirFeat As Inventor.MirrorFeature 
	oMirFeat = oMirs.AddByDefinition(oMirFeatDef)

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes