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

In case you want to use it in iLogic instead, here below is the translation.

I've removed the debugs and simplified the user parameter search. Also there's no need to cast it to PartDocument type.

You can apply these changes to your VBA makro as well. It would be a bit faster in parts with a lot of custom parameters as it doesn't iterate through all of them. Or let me know if you want me to do so for you.

 

Public Sub Main()
    ' Get the active assembly document.
    Dim oAsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
    ' Iterate through all of the documents referenced by the assembly.
    For Each oDoc As Document In oAsmDoc.AllReferencedDocuments
        ' Check to see if this is a part.
        If oDoc.DocumentType <> kPartDocumentObject Then Continue For
        Dim oUserParams As UserParameters = oDoc.ComponentDefinition.Parameters.UserParameters
        ' Check to see if the part document contains user parameters.
        If oUserParams.Count = 0 Then Continue For
        ' Look for user parameter named "G_L".
        Dim oUserParam As UserParameter =  oUserParams.Item("G_L")
        If oUserParam Is Nothing Then Continue For
        oUserParam.CustomPropertyFormat.Precision = kSixteenthsFractionalLengthPrecision
    Next oDoc
End Sub

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods