Cast16
Utente Standard
professione: Design Engineer
software: Inventor, Autocad, Solid Edge
regione: UK
@Spini
1. Aggiungi Regola1
2. Mettilo nel Event triggers
3. Crea Form
Tutto spiegato nel video di sotto.
Fammi sapere.
iLogic:
1. Aggiungi Regola1
2. Mettilo nel Event triggers
3. Crea Form
Tutto spiegato nel video di sotto.
Fammi sapere.
iLogic:
Codice:
' iLogic Rule: Aggiorna_Area_Totale
Dim partAreaPropName As String = "extents_area"
Dim drawingQtyPropName As String = "Qty"
Dim drawingTotalAreaPropName As String = "Total Area"
Dim oDoc As DrawingDocument
oDoc = ThisDrawing.Document
Dim oDrawingUserPropSet As PropertySet
Try
oDrawingUserPropSet = oDoc.PropertySets.Item("Inventor User Defined Properties")
Catch
MessageBox.Show("Il set di proprietà personalizzate del disegno 'Inventor User Defined Properties' non è stato trovato. Assicurarsi che le proprietà personalizzate siano utilizzate.", "Errore iLogic - Set Proprietà Mancante", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End Try
Dim qty As Double = 0.0
Dim oQtyProp As Inventor.Property = Nothing
Try
oQtyProp = oDrawingUserPropSet.Item(drawingQtyPropName)
If IsNumeric(oQtyProp.Value) Then
qty = CDbl(oQtyProp.Value)
Else
MessageBox.Show("Il valore della proprietà '" & drawingQtyPropName & "' nel disegno non è numerico. Verrà utilizzato il valore predefinito 1.", "Avviso iLogic - Qty Non Numerica", MessageBoxButtons.OK, MessageBoxIcon.Warning)
qty = 1.0
End If
Catch
Try
oQtyProp = oDrawingUserPropSet.Add(1.0, drawingQtyPropName)
qty = 1.0
MessageBox.Show("La proprietà personalizzata del disegno '" & drawingQtyPropName & "' non è stata trovata ed è stata creata con valore iniziale 1.", "Informazione iLogic - Qty Creata", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show("Impossibile creare la proprietà personalizzata del disegno '" & drawingQtyPropName & "': " & ex.Message, "Errore iLogic - Creazione Qty Fallita", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return
End Try
End Try
Dim area As Double = 0.0
Dim foundPartAndArea As Boolean = False
If oDoc.ReferencedDocuments.Count > 0 Then
For Each refDoc As Document In oDoc.ReferencedDocuments
If refDoc.DocumentType = kPartDocumentObject Then
Dim oPartUserPropSet As PropertySet
Try
oPartUserPropSet = refDoc.PropertySets.Item("Inventor User Defined Properties")
Catch
Continue For
End Try
Dim oAreaProp As Inventor.Property = Nothing
Try
oAreaProp = oPartUserPropSet.Item(partAreaPropName)
Dim sAreaValue As String = CStr(oAreaProp.Value).Trim()
If sAreaValue.EndsWith(" m^2") Then
sAreaValue = Left(sAreaValue, sAreaValue.Length - 4)
End If
sAreaValue = Replace(sAreaValue, ",", ".")
If IsNumeric(sAreaValue) Then
area = CDbl(sAreaValue)
foundPartAndArea = True
Exit For
Else
MessageBox.Show("Il valore della proprietà '" & partAreaPropName & "' nella parte '" & refDoc.DisplayName & "' ('" & oAreaProp.Value & "') non è numerico o non convertibile anche dopo la pulizia del formato. Verrà ignorato.", "Avviso iLogic - Area Parte Non Valida", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Continue For
End If
Catch
Continue For
End Try
End If
Next
End If
If Not foundPartAndArea Then
MessageBox.Show("Impossibile trovare una parte referenziata con la proprietà personalizzata '" & partAreaPropName & "' con un valore numerico valido (o nel formato atteso 'X.XX m^2').", "Avviso iLogic - Area Parte Non Trovata", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Return
End If
Dim totalArea As Double = area * qty
Dim oTotalAreaProp As Inventor.Property = Nothing
Try
oTotalAreaProp = oDrawingUserPropSet.Item(drawingTotalAreaPropName)
oTotalAreaProp.Value = totalArea
Catch
Call oDrawingUserPropSet.Add(totalArea, drawingTotalAreaPropName)
End Try
