Vytisknout stránku | Zavřít okno

Měření smyčky v náčrtu

Vytištěno z: CAD Fórum
Kategorie: Autodesk - stavebnictví, strojírenství, CAD/GIS
Název fóra: iLogic a ETO
Popis fóra: Funkce a makra iLogic, Inventor Engineering to Order (ETO), automatizace a konfigurace výrobků
URL: https://www.cadforum.cz/forum/forum_posts.asp?TID=18766
Datum vytištění: 06.kvě.2026 v 18:21


Téma: Měření smyčky v náčrtu
Odeslal: kosulic
Předmět: Měření smyčky v náčrtu
Datum odeslání: 18.úno.2014 v 09:33
Zkouším udělat pravidlo na měření smyčky z náčrtu (model řetězu)
Potřebuji vytvořit 4 parametry (nejlépe je označit pro export)
Změřit smyčku
vypočítat počet článků
vypočítat počet spojek

Nefunguje mi ale zaokrouhlování a nevím jak parametry označit pro export.
Kdyby se našla dobrá duše, která by mi pomohla, byl bych vděčný.


Try
    Param = ThisDoc.Document.ComponentDefinition.Parameters("DELKA_SMYCKY")
Catch
    Param = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByExpression("DELKA_SMYCKY", 1, "mm" )
End Try

Dim se As SketchEntity = ThisDoc.Document.ComponentDefinition.Sketches(1).SketchLines(1)  
Param.Expression =(ThisApplication.MeasureTools.GetLoopLength(se)*10 & " mm")
Parameter("DELKA_SMYCKY") = Round(DELKA_SMYCKY)

Try
    Param = ThisDoc.Document.ComponentDefinition.Parameters("ROZTEC_RETEZU")
Catch
    Param = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByExpression("ROZTEC_RETEZU", 1, "mm" )
End Try
Parameter("ROZTEC_RETEZU") = 12.7

Try
    Param = ThisDoc.Document.ComponentDefinition.Parameters("POCET_CLANKU")
Catch
    Param = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByExpression("POCET_CLANKU", 1, "ul" )
End Try
Parameter("POCET_CLANKU") = Round(DELKA_SMYCKY/ROZTEC_RETEZU)

Try
    Param = ThisDoc.Document.ComponentDefinition.Parameters("SPOJKA_POCET")
Catch
    Param = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByExpression("SPOJKA_POCET", 1, "ul" )
End Try
Parameter("SPOJKA_POCET") = Floor((DELKA_SMYCKY/5000))+1



Odpovědi:
Odeslal: Navara
Datum odeslání: 18.úno.2014 v 20:00
V tom kódu je několik formálních chyb a měl by vypadat takhle:
Dim Param As Parameter
Try
    Param = ThisDoc.Document.ComponentDefinition.Parameters("DELKA_SMYCKY")
Catch
    Param = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByExpression("DELKA_SMYCKY", 1, "mm")
End Try
Dim se As SketchEntity = ThisDoc.Document.ComponentDefinition.Sketches(1).SketchLines(1)
Dim delkaRetezu As Double = Math.Round(ThisApplication.MeasureTools.GetLoopLength(se)) * 10
Param.Expression = (delkaRetezu & " mm")
Try
    Param = ThisDoc.Document.ComponentDefinition.Parameters("ROZTEC_RETEZU")
Catch
    Param = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByExpression("ROZTEC_RETEZU", 1, "mm")
End Try
Dim roztecRetezu As Double = 12.7
Param.Expression = roztecRetezu & "mm"
Try
    Param = ThisDoc.Document.ComponentDefinition.Parameters("POCET_CLANKU")
Catch
    Param = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByExpression("POCET_CLANKU", 1, "ul")
End Try
Dim pocetClanku As Integer = Math.Round(delkaRetezu / roztecRetezu)
Param.Expression = pocetClanku & "ul"
Try
    Param = ThisDoc.Document.ComponentDefinition.Parameters("SPOJKA_POCET")
Catch
    Param = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByExpression("SPOJKA_POCET", 1, "ul")
End Try
Param.Expression = Math.Floor((delkaRetezu / 5000)) + 1 & "ul"
 
ale asi bych dal přednost zkrácené verzi s voláním funkce pro nastavení parametru a jeho p5enosem do iVlastnosti
 
Sub Main()
    Dim se As SketchEntity = ThisDoc.Document.ComponentDefinition.Sketches(1).SketchLines(1)
    Dim delkaRetezu As Double = Math.Round(ThisApplication.MeasureTools.GetLoopLength(se)) * 10
    SetParam("DELKA_SMYCKY", delkaRetezu, " mm")
    Dim roztecRetezu As Double = 12.7
    SetParam("ROZTEC_RETEZU", roztecRetezu, "mm")
    Dim pocetClanku As Integer = Math.Round(delkaRetezu / roztecRetezu)
    SetParam("POCET_CLANKU", pocetClanku, "ul")
    SetParam("SPOJKA_POCET", Math.Floor((delkaRetezu / 5000)) + 1, "ul")
End Sub
Sub SetParam(paramName As String, value As Double, units As String)
    Dim Param As Parameter
    Try
        Param = ThisDoc.Document.ComponentDefinition.Parameters(paramName)
    Catch
        Param = ThisDoc.Document.ComponentDefinition.Parameters.UserParameters.AddByExpression(paramName, 1, units)
    End Try
    Param.Expression = String.Format("{0} {1}", value, units)
    'Set as property
    Param.ExposedAsProperty = True
    Param.CustomPropertyFormat.Precision = CustomPropertyPrecisionEnum.kOneDecimalPlacePrecision
    Param.CustomPropertyFormat.PropertyType = CustomPropertyTypeEnum.kTextPropertyType
    Param.CustomPropertyFormat.ShowTrailingZeros = False
    Param.CustomPropertyFormat.ShowUnitsString = False
    '...
End Sub
 


Odeslal: kosulic
Datum odeslání: 20.úno.2014 v 10:49
Děkuji, mrknu na to a vyzkouším.



Vytisknout stránku | Zavřít okno