Weldment appearance

Weldment appearance

rafael.barata
Enthusiast Enthusiast
344 Views
8 Replies
Message 1 of 9

Weldment appearance

rafael.barata
Enthusiast
Enthusiast

Hello everyone,

 

May I ask for your help to create an iLogic rule? Something like this:

 

  • For each weldment in the assembly, or respective children (weldments only), read their specific weld appearance and force it as appearance property on those documents, so I can have it in BOM.

rafaelbarata_0-1748948051131.png

 

rafaelbarata_1-1748948134448.png

 

0 Likes
Accepted solutions (1)
345 Views
8 Replies
Replies (8)
Message 2 of 9

WCrihfield
Mentor
Mentor

Hi @rafael.barata.  Generally speaking, assemblies do not have a 'material' or an 'appearance' of their own.  They just represent the 'components' that we place into them.  Because of this,  the main iProperty named "Appearance" for an assembly document will not be meaningful.  In regular (not weldment) assemblies, there is only one thing that we can control the material of, and that is 'virtual' components, which have no visual representation anyways, and are just for adding custom rows into our BOM.  Then, when we have a weldment type assembly, we can additionally set the 'material' to use for the weld beads.  And yes, it does allow us set an override appearance for those weld beads, other than the weld bead material's own appearance.  But setting that is not the same as the main material or appearance for the overall assembly document though, just for the welds that get created within the assembly, if any.  There is actually a standard iProperty named "Weld Material" in the PropertySet named "Design Tracking Properties", which is the third PropertySet, and that property is item # 38 of its properties.  It has a String type value, but for most other types of documents, it will not have a value.  There is no iProperty for weld appearance though.  So, I'm not sure if what you are attempting to do is possible.

Those controls in the quick access toolbar for material and appearance drop-downs generally only show something meaningful when we have something within the assembly selected, as a convenience.  I do know how to set the material and appearance of weld beads within a weldment type assembly, but doubt that it would make any difference to anything within the BOM of a parent assembly.

Edit:  Attached is a text file containing code that can be used for an example iLogic rule.  That rule is designed to be ran while the 'main' (highest level) assembly is the 'active' document and/or the rule is saved within that assembly, then it will iterate through all of the documents being referenced at all levels within that assembly, find the ones that are weldment assemblies, and attempt to set the appearance of their weld beads to the one shown in your screen captured image.  Again, I am not sure if that will actually accomplish what you were hoping it would accomplish, but it is at least somewhere to start exploring / testing.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 9

rafael.barata
Enthusiast
Enthusiast

Hi @WCrihfield,

 

First of all, thank you for your answer and sorry the late reply.

Until AI2023, there was a bug that allowed to assign an appearance to weldment assemblies (only) in BOM environment. This bug allowed me to use the appearance property of parts and weld assemblies in .idw's legend title block to place the finishing that I wanted (Black oxide, paint, brushed, polished, etc...). It was a rule of thumb to assign the same appearance of the weld beads to the BOM property.

 

Since the bug was corrected in AI2024, in order to not invalidate every .idw that were made before and also to not create a new way of work for every designer in my firm, I need to force that property so I can still use it in legend title blocks. in a main assembly, i would run that rule and it will search every weld assemblies inside and force that appearance. Is that possible.

 

I also place here an excerpt of an answer from Johnson Shiue, when I asked him for help.

 

"Many thanks for sharing the 2023 files! I did confirm the behavior you are seeing. The issue here is that the Appearance style seems to have a unique behavior in BOM table. It seems to be the only way to change the “Appearance style” and also the style isn’t used anywhere visually except being the “Appearance” property shown in the drawing or BOM table.

This legacy behavior is somewhat corruptive, prone to have problems. It is why it is blocked in 2024 to prevent more corruptions.

I don’t think there is a good solution here. An iLogic rule might help “bypass” the behavior in 2024. For example, simply create an iLogic rule in the top-level assembly. Add the following statement. The Appearance property will be changed to Aluminum Casting.

 

iProperties.Value("22053AI-AS15-000:1", "Project", "Appearance")="Aluminum Casting""                                                                     "

 

Hope you can help me.

 

Best regards,

Rafael Barata

0 Likes
Message 4 of 9

WCrihfield
Mentor
Mentor

OK, well if he says it is possible, I will have to take his word for it, but the online help documentation says otherwise.  What I mean is, each of the first 4 PropertySets in every Document, and a special PropertySet only present in 'Content Center' stuff, has an 'Enum' for them.  There are online help pages for each of those Enums.  I will post those links below, for reference:

PropertiesForSummaryInformationEnum 

PropertiesForDocSummaryInformationEnum 

PropertiesForDesignTrackingPropertiesEnum 

PropertiesForUserDefinedPropertiesEnum 

PropertiesForContentLibraryEnum 

The standard Property named 'Appearance' is at the Index position of 53 in the third PropertySet, the one named "Design Tracking Properties".  When we look at the Enum for that PropertySet, and look at the line item for the Property named 'Appearance' (first one shown, due to alphabetical order), it says that it is ReadOnly, and says that it there is no user interface access to it.  That online help documentation may simply be outdated, and needs to be updated (hint @johnsonshiue).  When I use a line of code to set the value of that iProperty, I do not get an error, but that also does not really set the Appearance of that Document, in the traditional sense.  I believe that Property's value gets set automatically by Inventor when we set the 'real' appearance (an Asset object) of a Document, so its value gets driven by that action, not the other way around.  But if setting the value of that iProperty is all that is needed in your case, then that would certainly simplify things greatly.

Below is an updated code example using that process, but doing it the Inventor API way, instead of the iLogic API way, to help clarify document specification when dealing with referenced documents in the background.  This can be used directly on a weldment type assembly, or used from a parent level assembly containing some weldment type sub components.

Dim oADoc As AssemblyDocument = TryCast(ThisDoc.Document, Inventor.AssemblyDocument)
If oADoc Is Nothing Then Return
If TypeOf oADoc.ComponentDefinition Is WeldmentComponentDefinition Then
	oADoc.PropertySets.Item(3).Item(53).Value = "Decapage"
End If
For Each oRefDoc As Inventor.Document In oADoc.AllReferencedDocuments
	If Not TypeOf oRefDoc Is Inventor.AssemblyDocument Then Continue For
	Dim oRefADoc As AssemblyDocument = oRefDoc
	If Not TypeOf oRefADoc.ComponentDefinition Is WeldmentComponentDefinition Then Continue For
	oRefADoc.PropertySets.Item(3).Item(53).Value = "Decapage"
Next
oADoc.Update2(True)

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 9

rafael.barata
Enthusiast
Enthusiast

Once again, thank you for your answer. Your code works perfect. That's almost what I want. I ask you if you may make just one slight modification.

 

Instead of forcing the value, in this case, "Decapage", can you read the appearance of the welding bead, of each Weldment assembly, and use it as value for oRefADoc.PropertySets.Item(3).Item(53).Value?

 

The rest is perfect. It shows the value in BOM and I also can use it in idw's title block.

0 Likes
Message 6 of 9

WCrihfield
Mentor
Mentor
Accepted solution

Sure.  Here you go.  I broke this one down into two parts again, to simplify it even further, and make it slightly more dynamic/efficient.

Sub Main
	Dim oDoc As Inventor.Document = ThisDoc.Document
	SetWeldAppearanceAsDocAppearance(oDoc)
	For Each oRefDoc As Inventor.Document In oDoc.AllReferencedDocuments
		SetWeldAppearanceAsDocAppearance(oRefDoc)
	Next
	oDoc.Update2(True)
End Sub

Sub SetWeldAppearanceAsDocAppearance(doc As Inventor.Document)
	If Not TypeOf doc Is Inventor.AssemblyDocument Then Return
	Dim oADoc As AssemblyDocument = doc
	If Not TypeOf oADoc.ComponentDefinition Is WeldmentComponentDefinition Then Return
	Dim oWDef As WeldmentComponentDefinition = oADoc.ComponentDefinition
	oADoc.PropertySets.Item(3).Item(53).Value = oWDef.WeldBeadAppearance.DisplayName
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 7 of 9

rafael.barata
Enthusiast
Enthusiast

Hi,

It's perfect. Problem solved. Many thanks.

0 Likes
Message 8 of 9

christian_stecklum
New Member
New Member

Hi,

 

this thread is kind of old, but I currently have a similar problem. I'm trying to change the WeldBeadAppearance via the Inventor API, not iLogic. The reason is that we use the appearance color, namely RAL colors,  on our drawings for all products that are powder coated or painted and we use a UserForm to set the color. This works pretty good for part docs, but it doen't for weldment assemblies. I found out that I can set the appearance of weld beads and use this data on the drawings. I can change the appearance manually, and I even managed to do it by using a modified version of the iLogic rule you posted, but when I try to set it using a macro, it doesn't work. 

Here's a code sample: 

Sub SetWeldBeadAppearance()

Dim objInvApp As Inventor.Application
Dim objInvDoc As Inventor.Document
Dim strAppName As String
Dim objWeldDef As WeldmentComponentDefinition
Dim objAppAsset As Inventor.Asset
Dim objAssetLib As Inventor.AssetLibrary

    Set objInvApp = ThisApplication
    Set objInvDoc = objInvApp.ActiveDocument

    If objInvDoc Is Nothing Then
        Call MsgBox("No open document found", vbExclamation + vbOKOnly)
        Exit Sub
    End If

    If objInvDoc.ComponentDefinition.Type <> ObjectTypeEnum.kWeldmentComponentDefinitionObject Then
        Call MsgBox("for weldment assembly only", vbExclamation + vbOKOnly)
        Exit Sub
    End If
    
    'constant val just for testing
    strAppName = "RAL 1001 Beige"
    
    Set objWeldDef = objInvDoc.ComponentDefinition
    
    For Each objAssetLib In objInvApp.AssetLibraries
        Debug.Print objAssetLib.DisplayName
        For Each objAppAsset In objAssetLib.AppearanceAssets
            If objAppAsset.DisplayName = strAppName Then
                'Debug.Print objAppAsset.DisplayName
                objWeldDef.WeldBeadAppearance = objAppAsset
                Exit For
            End If
        Next
        If objWeldDef.WeldBeadAppearance.DisplayName = strAppName Then
            Exit For
        End If
    Next
    
End Sub

 The probem is the command "objWeldDef.WeldBeadAppearance = objAppAsset", which returns a runtime error 5 (invalid procedure call or argument). When I try "set objWeldDef.[...]" instead, I get a compile error (invalid use of property). I must confess that I'm not a programmer, so I'm probably messing something up here. Any help is highly appreciated.

 

Best regards

Chris

0 Likes
Message 9 of 9

WCrihfield
Mentor
Mentor

Hi @christian_stecklum.  I can not be 100% sure, but I suspect this problem may be that the Asset object that you find in the AssetLibrary needs to be copied to the assembly Document first, then the resulting copy obtained from the Document could be set as the value of that property within the document.  When we do things manually, through the user interface, usually a lot of other stuff is automatically going on behind the scenes to make our experience go smoother, and simpler.  I believe one of those things that happens automatically for us when doing things manually is copying the Asset object from some external library file down into our local Document object for us when we want to set it to something in the model.  Sometimes when doing things by code, we often to not have those automatic helpers aiding our efforts because our intentions are not always predictable.  I believe the external asset first needs to be copied down to the document, then that document asset can be used within that document.  When we manually open the material or appearance browser dialog, there is usually an upper portion and a lower portion.  The upper portion usually contains the 'local copies' that exist within that document, usually because we have used them in that document at some point.  Then the lower portion is looking at one of the external libraries, to show what is available.  Even in that context, there are contextual controls for copying assets from the external library up into the document's local storage area.

So, the minimal change that may be required within your existing code may be this following line of code:

objAppAsset = objAppAsset.CopyTo(objInvDoc, True)

...which could be inserted between this line:

 If objAppAsset.DisplayName = strAppName Then

...and this line:

objWeldDef.WeldBeadAppearance = objAppAsset

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes