Suppress/make invisible weldment features with iLogic

Suppress/make invisible weldment features with iLogic

relicseekerharry
Contributor Contributor
136 Views
6 Replies
Message 1 of 7

Suppress/make invisible weldment features with iLogic

relicseekerharry
Contributor
Contributor

I am writing an iLogic rule for a configurator that enables/disables welded bosses based on certain criteria. Suppressing the bosses is simple, but their welds persist and look out of place. Attached is some sample iLogic that fails (the .Suppressed property has the same effect). It is my understanding that weldments use a different API to non-weldments so the error message from this "Public member 'Visible' on type 'WeldBead' not found." is to be expected.

 

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oWeldDef As WeldmentComponentDefinition = oDoc.ComponentDefinition

oWeldDef.Welds.Item("Weld 1").Visible = True
oWeldDef.Welds.Item("Weld 2").Visible = False

 

So, how do I get around this to programmatically disable or make a weldment feature invisible?

0 Likes
Accepted solutions (1)
137 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

I believe similar questions have been asked multiple times before on this forum, but I have never seen a method to hide or suppress individual weld beads yet.  I suspect that ability simply has not been exposed to us yet through Inventor's API.  I think maybe the only way is to simulate the user interactions way of doing it, which would be to navigate the browser nodes in the model browser tree, select the browser node, then execute the command behind the context menu option.  There are is likely some example code of how to do that somewhere in this forum, because I have done similar routines before.

Edit:  Here is a Link to one such discussion on this forum that I was involved with in the past, which shows most of this.

https://forums.autodesk.com/t5/inventor-programming-forum/suppressing-welds/m-p/9673020 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 7

mfoster9TD82
Advocate
Advocate

I would suggest looping through all occurrences and change visible to false on all that contain the name "Weld". I was able to do it that way.

https://forums.autodesk.com/t5/inventor-programming-forum/turn-off-visibility-of-welds-in-an-occurre...

 

For Each oOccurrence As ComponentOccurrence In oAssy.ComponentDefinition.Occurrences
	If (oOccurrence.Name.Contains("Weld"))
		For Each oSubOcc As ComponentOccurrence In oOccurrence.SubOccurrences
			oSubOcc.Visible = False
		Next
	End If
Next
Message 4 of 7

relicseekerharry
Contributor
Contributor

I have some welds that need to stay active no matter what, so I have modified your code to suit my needs:

Dim oDoc As AssemblyDocument = ThisDoc.Document
For Each oOccurrence As ComponentOccurrence In oDoc.ComponentDefinition.Occurrences
	If (oOccurrence.Name.Contains("Weld"))
		For Each oSubOcc As ComponentOccurrence In oOccurrence.SubOccurrences
			If (oSubOcc.Name.Contains("Tray Weld")) Then
				oSubOcc.Visible = False
			End If
		Next
	End If
Next

However, the target weld does not get made invisible, and the .Suppressed property refuses to be anything but read-only. Do you have any tips going from here? 

0 Likes
Message 5 of 7

WCrihfield
Mentor
Mentor
Accepted solution

To explain that situation a little better, there are two weld related types of component occurrences that you may encounter when iterating through all component occurrences in an assembly.  Their 'Type' can be determined using a few additional lines of code which utilize the TypeOf Operator to compare them against the known types that we are expecting.  One of those types is an occurrence representing a weldment type assembly, whose 'Definition' will be the WeldmentComponentDefinition Type.  The other is an occurrence whose definition is the WeldsComponentDefinition Type, which represents the 'Welds' that are present within a weldment type assembly.  However, there is usually just one of those occurrences within a weldment type assembly, even if there are multiple actual weld beads in it.  So, there will not be individual assembly occurrences for each weld bead.  There are such things as Welds, Weld, WeldBeads, WeldBead objects which we can actually navigate down to through Inventor's API, but they simply do not have the properties or methods that you want for turning on/off their visibility or suppression status changes.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 6 of 7

relicseekerharry
Contributor
Contributor

Hopefully the 2027 version has our backs! Working with weldments is so much more annoying than standard parts and assemblies!

0 Likes
Message 7 of 7

WCrihfield
Mentor
Mentor

Just going to add a bit more information to this post, to help save others some time later, if they should attempt to try some alternative ways to do this.  When we are in a weldment type assembly, there are 4 different 'editing modes' or 'environments' (the default assembly mode, the preparations mode, the welds mode, and the machining mode).  We can activate or exit each of those modes by code also.  Since it would seem logical to edit or modify a weld bead while in welds mode, I did try several of the usual ways to suppress or hide a weld bead while in both the default assembly mode, and while in welds mode, but the mode did not seem to make a difference.  I also checked in the WeldsComponentDefinition.Occurrences collection, but it does not contain any occurrences.  Another angle that was explored was utilizing the SurfaceBody.Visible property.  The WeldsComponentDefinition.SurfaceBodies collection only contained 1 body, even though several welds of different types existed in it.  When that one body was highlighted, all the welds of all types were highlighted, so they were all part of one SurfaceBody object.  So, no luck there either.  I also tried multiple ways of selecting a single Inventor.WeldBead object, but most of those fail also.  For example, the Document.SelectSet.Select() method would not select it ; the CommandManager.DoSelect() method would not select it.  I also tried using the shortcut way to get the Inventor.BrowserNode for that WeldBead directly (BrowserPane.GetBrowserNodeFromObject method), but that failed also.  So, to select it prior to executing the ControlDefinition for toggling its suppression, I had to step down through the model browser nodes the traditional way, then use its BrowserNode.DoSelect method, just like in the older posts.  Sometimes there are multiple ways to get something done...other times there mostly just multiple ways to fail at getting something done, but just one way that works.  🙄😉

Wesley Crihfield

EESignature

(Not an Autodesk Employee)