Pattern component - zero elimination

Pattern component - zero elimination

AudriusM
Participant Participant
379 Views
5 Replies
Message 1 of 6

Pattern component - zero elimination

AudriusM
Participant
Participant

 

Hello, has anyone encountered and knows a method? 
How to obtain the decimal part of a double variable in this function?
How to reduce trailing zeros after the decimal point?
-----------
columnOffset As Double
----------
If
(Not oName Is Nothing) Then Start : oInput = InputBox("Enter a quantity:", "Virtual Part PATTERN", "1") numericCheck = IsNumeric(oInput) If numericCheck = True Then Else GoTo Start End If oCurFileName = oName.Name oFileName = iProperties.Value(oName.Name, "Project", "Description") Patterns.AddRectangular(oFileName, oCurFileName, oInput, 2, Nothing, "X Axis") End If
---------

https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=7d8a2ed5-bf8e-7908-430a-4a62edadc8ad

x1.JPG

 

 

0 Likes
Accepted solutions (2)
380 Views
5 Replies
Replies (5)
Message 2 of 6

Frederick_Law
Mentor
Mentor

oInput_Decimal = oInput - Int(oInput)

 

Number of decimal shown is set in document property.

 

Since the pattern count is integer, just declare it as Integer.

Only allow Integer input in dialog.

0 Likes
Message 3 of 6

AudriusM
Participant
Participant

Do you have any examples or snippets of code where this works? No matter how hard I try, passing an integer-type variable to the function doesn't seem to have any effect.

0 Likes
Message 4 of 6

Frederick_Law
Mentor
Mentor

From the Help page you attached, columnCount is Integer:

Function AddRectangular ( 
	patternName As String,
	parentComponents As ComponentOrPattern,
	columnCount As Integer,
	columnOffset As Double,
	columnComponent As ComponentArgument,
	columnEntityName As String,
	Optional columnNaturalDirection As Boolean = true,
	Optional rowCount As Nullable(Of Integer) = Nothing,
	Optional rowOffset As Nullable(Of Double) = Nothing,
	Optional rowComponent As ComponentArgument = Nothing,
	Optional rowEntityName As String = Nothing,
	Optional rowNaturalDirection As Boolean = true
) As ManagedPattern

 

0 Likes
Message 5 of 6

yuzeaa
Advocate
Advocate
Accepted solution

It seems like ilogic only support numeric value input,but api can also input expression string value。You may not be able to get the results you want through ilogic function.

Dim occ = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select an Occurrence")
Dim oEdge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeLinearFilter, "Select an Edge")
Dim oAsmDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition
Dim oCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oCollection.Add(occ)
oAsmDef.OccurrencePatterns.AddRectangularPattern(oCollection, oEdge, True, "100 mm", "5 ul")
'oAsmDef.OccurrencePatterns.AddRectangularPattern(oCollection,oEdge,True,10,5)
0 Likes
Message 6 of 6

AudriusM
Participant
Participant
Accepted solution

Thank you, your adjusted method proved successful, everything worked perfectly.

 

Dim oAsmDef As AssemblyComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition
Dim oCollection As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oCollection.Add(virtOcc)

patternQuantity = InputBox("Enter pattern quantity:", "Pattern Quantity", "1")
oFileName = iProperties.Value(virtOcc.Name, "Project", "Description")
oPattern = oAsmDef.OccurrencePatterns.AddRectangularPattern(oCollection, oAsmDef.WorkAxes.Item("Z Axis"), True, "2 mm", patternQuantity)
oPattern.Name = oFileName

 

0 Likes