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

Error when round value to 2th decimal

Neuzzo
Advocate

Error when round value to 2th decimal

Neuzzo
Advocate
Advocate

Hi, I have a problem with this macro:
the final value of "iProperties.Value("Custom", "DCM_Laser")" I can't round it to the second decimal place: e.g. 0.00
When I try to add the (value, 2) in the expression I get this error:

Neuzzo_0-1670591178029.png

Dim oDoc As Document = ThisApplication.ActiveDocument
	If Not oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
		Exit Sub
	End If
	If Not oDoc.IsModifiable = True Then
		Exit Sub
	End If
	If Not oDoc.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
		Exit Sub
	End If
Dim oSMDoc As PartDocument = ThisApplication.ActiveDocument
Dim oSMDef As SheetMetalComponentDefinition = oSMDoc.ComponentDefinition
If oSMDef.HasFlatPattern = False Then
	MsgBox("Manca il modello piatto.", vbOKOnly, "NO FLAT PATTERN")
	Exit Sub
End If
Dim oCompOcc As ComponentOccurrence
	iProperties.Value("Custom", "DCM_Lamiera") = "T"
	Dim oTopFace As Face = oSMDef.FlatPattern.TopFace
	Dim oMeasureTools As MeasureTools = ThisApplication.MeasureTools
	Dim oLoopLength As Double = 0.00
		For Each oEdgeLoop As EdgeLoop In oTopFace.EdgeLoops
		oLoopLength = oLoopLength + oMeasureTools.GetLoopLength(oEdgeLoop)
	Next
If iProperties.Material = "801171 AISI 304 sp.1 2B"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8,2)
	Else If iProperties.Material = "801181 AISI 304 sp. 1.2 2B"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/7.7)
	Else If iProperties.Material = "801211 AISI 304 sp. 2 2B"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/5)
	Else If iProperties.Material = "811151 AISI 304 sp. 0.8 SB + PVC"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8.2)
	Else If iProperties.Material = "811175 AISI 304 sp. 1 SB + PVC"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8)
	Else If iProperties.Material = "811181 AISI 304 sp. 1.2 SB + PVC"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/7.7)
	Else If iProperties.Material = "811191 AISI 304 sp. 1.5 SB + PVC"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/7)
	Else If iProperties.Material = "811194 AISI 304 sp. 2 SB + PVC"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/4.6)
	Else If iProperties.Material = "811196 AISI 304 sp. 3 SB + PVC"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/2.5)
	Else If iProperties.Material = "811501 AISI 430 sp. 3 BA"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/2.5)
	Else If iProperties.Material = "811525 AISI 430 sp. 0.8 BA"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8.2)
	Else If iProperties.Material = "811531 AISI 430 sp. 0.8 SB + PVC"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8.2)
	Else If iProperties.Material = "811535 AISI 430 sp. 0.8 SB + PVC"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8.2)
	Else If iProperties.Material = "811541 AISI 430 sp. 1 SB + PVC"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8)
	Else If iProperties.Material = "811547 AISI 430 sp. 1 BA"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8)
	Else If iProperties.Material = "811583 AISI 430 sp. 1.5 BA"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/7)
	Else If iProperties.Material = "811585 AISI 430 sp. 1.5 BA + PVC"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/7)
	Else If iProperties.Material = "811587 AISI 430 sp. 2 BA"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/4.6)
	Else If iProperties.Material = "811813 ALLUMINATA sp. 0.8"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8.2)
	Else If iProperties.Material = "811817 ALLUMINATA sp. 1"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8.2)
	Else If iProperties.Material = "811819 ALLUMINATA sp. 1.5"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/7)
	Else If iProperties.Material = "811823 ALLUMINATA sp. 2"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/5)
	Else If iProperties.Material = "811931 Fe sp. 2"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/5.5)
	Else If iProperties.Material = "811937 Fe sp. 3"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/4)
	Else If iProperties.Material = "811939 FE-ZINCATO sp. 2"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/5.5)
	Else If iProperties.Material = "811941 FE-ZINCATO sp. 3"
		iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/4)
End If

 

 

How can I solve it? Thank you

Danilo "DannyGi" G.
Mechanical design engineer and product developer
0 Likes
Reply
Accepted solutions (1)
161 Views
2 Replies
Replies (2)

CattabianiI
Collaborator
Collaborator
Accepted solution

try this one:

iProperties.Value("Custom", "DCM_Laser") = Round((oLoopLength/100)/8, digits := 2)
0 Likes

Neuzzo
Advocate
Advocate
It work. Thank you
Danilo "DannyGi" G.
Mechanical design engineer and product developer
0 Likes