Input the number of circular patterns as a parameter

Input the number of circular patterns as a parameter

ysbaodnj
Enthusiast Enthusiast
247 Views
3 Replies
Message 1 of 4

Input the number of circular patterns as a parameter

ysbaodnj
Enthusiast
Enthusiast

hello
I completed the code to create a pattern using iLogic code.
I would like to input the number of patterns as a parameter so that the number of patterns changes depending on the parameter value.
However, since it is entered as a value rather than a parameter, the model does not change even if the parameter changes.
In the code, only integer values can be entered.
What should I do?
Please refer to the code below.

 

If (oCompName = "HOLDER-A:" & i) Or (oCompName = "HOLDER-B:" & i) Then 
  Dim patName As String = oCompName & ":PATTERN"
  Dim patAngl As Integer = 360 / pAts
  Dim circPattern = Patterns.AddCircular(patName, oCompName, Parameter("HOLA_C"), patAngl, oCompName, "Z축", axisNaturalDirection := True, lockRotation := False)
0 Likes
248 Views
3 Replies
Replies (3)
Message 2 of 4

alexanderboogaard
Enthusiast
Enthusiast

Hi,

 

Assuming that the code block iterates through all components and the oCompName is correctly reading the occurence.Name the following should be checked:

First, make sure that your parameter type for the number of patterns is unitless:

alexanderboogaard_0-1698397675365.png

 

 

If (oCompName = "HOLDER-A:" & i) Or (oCompName = "HOLDER-B:" & i) Then 
  Dim patName As String = oCompName & ":PATTERN"
  Dim patAngl As Integer = 360 / pAts
  Dim circPattern = Patterns.AddCircular(patName, oCompName, pAts, patAngl, oCompName , "Z축", axisNaturalDirection := True, lockRotation := False)
End If

 

 

What is changed is the reference to 'pAts' in the function for the pattern.

Please let me know if it worked. If not, please share the code where oCompName is declared to get a better understanding.


Kind regards,
Alexander Boogaard
0 Likes
Message 3 of 4

CCarreiras
Mentor
Mentor

Hi!

 

You need an Integer number to use as the pattern repetition number.

 

But, If your pattern value comes from an function, sometimes you will not get an integer number:

 

CCarreiras_1-1698400722207.png

 

Anyway, you can use some operators (similar to excel)to achieve the Integer number:

CCarreiras_2-1698400948423.png

In this case i selected the lower Integer value, but you can set other options:

CCarreiras_0-1698400393309.png

Tip: the units must be UL (unitless).

 

CCarreiras

EESignature

0 Likes
Message 4 of 4

ysbaodnj
Enthusiast
Enthusiast

The part where pAts is defined is omitted..
pAts = Parameter("HOLA_C"),

 

ysbaodnj_0-1700479094154.png

 

Dim aOcc As Inventor.ComponentOccurrence = ThisApplication.CommandManager.Pick(kAssemblyOccurrenceFilter, "Pick contente part to be patterned")
Dim oCompName As String = aOcc.Name

 

Waiting for your reply... 

0 Likes