Circular patterns feature strange results

Circular patterns feature strange results

Anonymous
Not applicable
1,252 Views
5 Replies
Message 1 of 6

Circular patterns feature strange results

Anonymous
Not applicable

 Hello,

 

I'm trying to create a circular pattern feature using a PartComponentDefinition.Features.CircularPatternFeatures.AddByDefinition() method, and I'm getting unexpected results. The problem lies in the fact that the angle given by me is for some reason not used BUT an angle 229.183118052 is constantly used. I tried to specify an angle using parameters below: "360 deg", convert degrees to radians, but always using the angle 229.183118052. Thanks for any help!

 

Screenshot_2.pngScreenshot_3.png

That's what I get (wrong)

Screenshot_1.png

That's what i want
Screenshot_4.png


UPD: Specifiing the needed angle using CircularPatternFeature.Angle._Value property after building circular pattern is solving my problem, but it seems in the API method there is a bug.

 

 

0 Likes
Accepted solutions (3)
1,253 Views
5 Replies
Replies (5)
Message 2 of 6

AlexFielder
Advisor
Advisor

I'd like to add my +1 to this exact error. Using iLogic however means I am unable to use the ._Value fix that was added to the OP.

0 Likes
Message 3 of 6

AlexFielder
Advisor
Advisor
Accepted solution

Because it might save others (and me, no-doubt) time in the future (at least until Autodesk push out a fix!?) here's my solution that kludges this broken API mechanic and gets the last-created parameter object reassigning its value to the desired parameter:

 

(NOTE: you will need to add "Imports System.Linq" & "Imports System.Collections.Generic" on separate lines at the top of any iLogic rule you use this within.

It also relies upon a "PatternRotation" parameter whose units are degrees.)

Dim oRotation As String = PatternRotation
	Dim circularPatternDef As CircularPatternFeatureDefinition = oCompDef.Features.CircularPatternFeatures.CreateDefinition(objColl, oCompDef.WorkAxes("Z Axis"), False, 4, "PatternRotation") ' The PatternRotation parameter used here results in the same value as OP no matter what!
	Parameter.UpdateAfterChange = True
	Dim circularPat As CircularPatternFeature = oCompDef.Features.CircularPatternFeatures.AddByDefinition(circularPatternDef)
	circularPat.SetEndOfPart(True) 'move the EOP so things don't KABOOM
	'THIS IS A KLUDGE TO FIX AUTODESK'S BUG AND SHOULDN'T BE NECESSARY!:
	Dim ModelParamList As List(Of ModelParameter) = New List(Of ModelParameter)
	For Each MParameter As ModelParameter In oCompDef.Parameters.ModelParameters
		ModelParamList.Add(MParameter)	
	Next
	
	'debug information
	MessageBox.Show(ModelParamList.Count)
	Dim maxParam As Parameter = Nothing
	Dim maxParamNum As Integer = 0
	If ModelParamList.Count > 0 Then
		ModelParamList.Sort(Function(x As ModelParameter, y As ModelParameter) x.Name.CompareTo(y.Name)) 'would usually use list.OrderBy() extension method here, but iLogic doesn't recognise it!
		maxParam = (From param As ModelParameter In ModelParamList Select param).Last()
	End If
	Dim p As ModelParameter = maxParam ' should probably error check this but it works for me!
	p.Expression = "PatternRotation"
	oCompDef.SetEndOfPartToTopOrBottom(False)
Message 4 of 6

Anonymous
Not applicable
Accepted solution

Hi,

 

I've got the same issue, fixed it for now by doing this:

 

// Create circular pattern off features
ObjectCollection features = m_inventorApplication.TransientObjects.CreateObjectCollection();
features.Add(*your features to pattern*);
WorkAxis wa = prtDoc.ComponentDefinition.WorkAxes[3]; // Z-Axis
object angle = (360 * 180 / Math.PI);
object amount = 4;
CircularPatternFeatureDefinition cpfd = prtDoc.ComponentDefinition.Features.CircularPatternFeatures.CreateDefinition(features, wa, false, amount, angle, true);
CircularPatternFeature cpf = prtDoc.ComponentDefinition.Features.CircularPatternFeatures.AddByDefinition(cpfd); // ANGLE CIRCULAR PATTERN FIX FOR ERROR IN AUTODESK INVENTOR API, ANGLE NEVER RETURNS CORRECTLY ModelParameter mp = prtDoc.ComponentDefinition.Parameters.ModelParameters[prtDoc.ComponentDefinition.Parameters.ModelParameters.Count]; mp.Expression = "360 deg";

I just changed the last made parameter right after creating the CircularPatternFeature.

 

Message 5 of 6

dgreatice
Collaborator
Collaborator
Accepted solution

Hi,

 

try add more line of your code after AddByDefinition :

 

CirCularPatternFeature.Parameters.item(1).Expression = "360 deg"

 

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
Message 6 of 6

wesleyosamigos
Community Visitor
Community Visitor

Opa, acredito que a melhor forma é adicionar a operação e posteriormente alterar a propriedade do ângulo

 

Dim oPatern As CircularPatternFeatureDefinition
Set oPatern = pDef.FlatPattern.Features.CircularPatternFeatures.CreateDefinition(obj, fc, True, Furos, 1)

 

Dim Pattern As CircularPatternFeature
Set Pattern = pDef.FlatPattern.Features.CircularPatternFeatures.AddByDefinition(oPatern)

 

Pattern.Definition.Angle.Expression = "360 deg"

 

 

 

 

Translation:

Hello, I believe the best way is to add the operation and later change the angle property

Dim oPatern As CircularPatternFeatureDefinition
Set oPatern = pDef.FlatPattern.Features.CircularPatternFeatures.CreateDefinition(obj, fc, True, Furos, 1)

 

Dim Pattern As CircularPatternFeature
Set Pattern = pDef.FlatPattern.Features.CircularPatternFeatures.AddByDefinition(oPatern)

 

Pattern.Definition.Angle.Expression = "360 deg"

 

Traduzido por [@clacampos] através do Google Tradutor

 

0 Likes