Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

How do I change iLogic?

cjfgns1003
Advocate

How do I change iLogic?

cjfgns1003
Advocate
Advocate

I created iLogic below.
However, I do not want to display the "Length" value among the iProperties values.
How can I change iLogic?

 

Sub main
    Dim oDoc As PartDocument = ThisDoc.Document
    Dim oDef As PartComponentDefinition = oDoc.ComponentDefinition
	Dim LengthTotal As Double = 0
	Dim oPath As Path
	For Each oSweep As SweepFeature In oDef.Features.SweepFeatures
		oPath = oSweep.Definition.Path
		LengthTotal = LengthTotal + GetLengthOfSweep(oPath)
	Next

    Dim oUParams As UserParameters = oDoc.ComponentDefinition.Parameters.UserParameters
    Dim oExists As Boolean = False
	Dim oParamName As String = "Length"
    For Each oUParam As UserParameter In oUParams
    	If oUParam.Name = oParamName Then
			oUParam.Value = LengthTotal
			oExists = True
		End If
    Next

    If oExists = False Then
        oUParams.AddByValue(oParamName, LengthTotal, UnitsTypeEnum.kDefaultDisplayLengthUnits)
    End If
	ParaExport(oDef.Parameters.UserParameters, oParamName, kZeroDecimalPlacePrecision)	
    oDoc.Update
	iProperties.Value("custom", "SIZE1") = "t" & Parameter("T0") & "x(" & Round(Parameter("Length"), 1) & ")x" & Round(Parameter("V0"), 1)
End Sub


Private Function GetLengthOfSweep(ByVal oPath As Path) As Double
    Dim TotalLength As Double = 0
    Dim oCurve As Object
	Dim oCurveEval As CurveEvaluator
	Dim MinParam As Double
    Dim MaxParam As Double
    Dim length As Double
    For i As Integer = 1 To oPath.Count
        oCurve = oPath.Item(i).Curve 
        oCurveEval = oCurve.Evaluator
        oCurveEval.GetParamExtents(MinParam, MaxParam)
        oCurveEval.GetLengthAtParam(MinParam, MaxParam, length)
        TotalLength = TotalLength + length
    Next
	Return TotalLength
End Function

Private Sub ParaExport(ByRef oUParas As UserParameters, ByVal oParaName As String, _
						ByVal oDecimalPrecision As CustomPropertyPrecisionEnum)
    For Each oUPara As UserParameter In oUParas
		If oUPara.Name = oParaName Then
            oUPara.ExposedAsProperty = True
			Dim oCPF As CustomPropertyFormat = oUPara.CustomPropertyFormat
			oCPF.PropertyType = CustomPropertyTypeEnum.kNumberPropertyType
            oCPF.Precision = oDecimalPrecision
			oUPara.Comment = "스윕길이로 산출함."
            Exit Sub
        End If
    Next
End Sub

 

cjfgns1003_1-1710295590225.png

 

0 Likes
Reply
Accepted solutions (1)
293 Views
4 Replies
Replies (4)

A.Acheson
Mentor
Mentor
Accepted solution

Hi @cjfgns1003 

This line here expose the parameter as an iProperty. Comment off as needed. See API Help here for parameter.ExposedAsProperty.

 

'oUPara.ExposedAsProperty = True

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

cjfgns1003
Advocate
Advocate
I want to hide only the "Length" value. How many times do I have to edit the row?
0 Likes

A.Acheson
Mentor
Mentor

Not sure what you mean by your question.

1. Do you mean delete existing length column? 2. Or to just not expose length parameter only as iproperty?

 

For 2 either 

Switch off the parameter export sub routine for the parameter or create an if statement in that routine to avoid the name length.

Private Sub ParaExport(ByRef oUParas As UserParameters, ByVal oParaName As String, _
						ByVal oDecimalPrecision As CustomPropertyPrecisionEnum)
    For Each oUPara As UserParameter In oUParas
        If oUPara.Name = "Length" Then
Else oUPara.ExposedAsProperty = True
End if

If oUPara.Name = oParaName Then Dim oCPF As CustomPropertyFormat = oUPara.CustomPropertyFormat oCPF.PropertyType = CustomPropertyTypeEnum.kNumberPropertyType oCPF.Precision = oDecimalPrecision oUPara.Comment = "스윕길이로 산출함." Exit Sub End If Next End Sub

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes

cjfgns1003
Advocate
Advocate
Just make sure that the length parameter is not exposed as an iproperty.
0 Likes