Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic Automate Assemblies

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
Anonymous
1050 Views, 11 Replies

iLogic Automate Assemblies

I'm trying to set up a rule for steel tank assemblies that will allow me to auto update the sheet metal parts required to build the tank. I know this can be done using adaptivity, but that would require a rework of all our standard tank designs whereas a rule can be injected much quicker. 

The sheet metal parts are already set up to run off a few driving user parameters. I replicated the driving parameters on the iam level and wrote this rule to force the parts to update to the iam dimensions. 

 

Is there a better way to reference the sheet metal parts? I can't call out the name directly because the rule has to work for multiple iams and we use distinct file names for all the sheet metal. Right now the rule pulls the filename of the first and second item in the model tree and works but will start to fail if anyone reorders the model tree. I'm in 2016.

 

SyntaxEditor Code Snippet

'Rect Param Match'2 plt design

Dim TheAsm As AssemblyDocument = ThisDoc.Document
Top = TheAsm.ComponentDefinition.Occurrences.Item(1).Name
Bottom = TheAsm.ComponentDefinition.Occurrences.Item(2).Name

'Parameter Matching, Top'Replace asm Param(s) "LNG" with "Parameter("LNG")" to run external
Parameter(Top, "LNG") = LNG
Parameter(Top, "WTH") = WTH
Parameter(Top, "HGT") = HGT
Parameter(Top, "THK") = THK

'Parameter Matching, Bottom
Parameter(Bottom, "LNG") = LNG
Parameter(Bottom, "WTH") = WTH
Parameter(Bottom, "HGT") = HGT
Parameter(Bottom, "THK") = THK

'Update
InventorVb.DocumentUpdate()

 

11 REPLIES 11
Message 2 of 12
Curtis_Waguespack
in reply to: Anonymous

Hi ascott_shipco,

 

Typically what we would do is "stabilize" the browser names so that the ilogic rules can find the components by name, even though the file names are going to change with each design.

 

So in the browser T-PLT-21DMES:1 gets renamed to something like TANK TOP,

and B-PLT-21DMES:1 gets renamed to TANK BOTTOM, etc.

 

Then you can create an array list and do a for each like this:

 

Dim oComponentList As New ArrayList
oComponentList.add("TANK TOP")
oComponentList.add("TANK BOTTOM")

For Each oItem In oComponentList
	Parameter(oItem, "LNG") = LNG
	Parameter(oItem, "WTH") = WTH
	Parameter(oItem, "HGT") = HGT
	Parameter(oItem, "THK") = THK
Next

'Update
InventorVb.DocumentUpdate()

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Message 3 of 12
Anonymous
in reply to: Curtis_Waguespack

How do you set a browser name different from a file name? I'm not familiar with "browser name." Is it the same as display name?

Message 4 of 12
Curtis_Waguespack
in reply to: Anonymous


@Anonymous wrote:

How do you set a browser name different from a file name? I'm not familiar with "browser name." Is it the same as display name?


Hi ascott_shipco,

 

Correct  "browser name" = display name.

 

Just select the component in the browser and then click it again to rename it.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 5 of 12
Anonymous
in reply to: Curtis_Waguespack

Any idea about the fastest way to update the display name for 1000+ part files?

Message 6 of 12
Curtis_Waguespack
in reply to: Anonymous

Hi ascott_shipco,

 

update this for 1000 files in an assembly?

Or 1000 files in many different assemblies?

Or 1000 files just in folders on disk, not tied to any assembly.

 

If I understand what you're attempting to do, I think you need to update the browser display name for the parts from within your assemblies.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 7 of 12
Anonymous
in reply to: Curtis_Waguespack

We use vault. 

Each part is unique to only 1 iam. Each iam contains 2-10 pieces of sheet metal to form the outer shell. The filenames are already set up along the lines of T-PLT-21DMES where T stands for TOP, PLT for plate steel, and the rest identifies the iam it belongs to. Point is, I know at a glance what each display name needs to become and the files are capable of tracking their own display name independent of the iam. 

I did a quick verification by putting this rule on 1 part and then opening the iam that the part belonged to. TADA! setting the display name on the ipt level brought the correct name into the iam. (I also saw that the display name that comes up can still be overwritten with a "browser name" tracked by that particular iam. If I open that same part in a new iam it reverts back to the display name I set.)

So there has to be a more time effective way to tell the parts to track their own display names without opening every iam.  

It seems like the display name property is being tracked similar to an iProperty but It doesn't show up through the Edit Properties tool in vault. Is there a way to access it without iLogic? 

Dim ThePart As PartDocument = ThisDoc.Document

ThePart.DisplayName = "Test-Name"

 

 

Message 8 of 12
Curtis_Waguespack
in reply to: Anonymous

 

 

Hi ascott_shipco,


@Anonymous wrote:

We use vault. 

Each part is unique to only 1 iam. Each iam contains 2-10 pieces of sheet metal to form the outer shell. The filenames are already set up along the lines of T-PLT-21DMES where T stands for TOP, PLT for plate steel, and the rest identifies the iam it belongs to.

 


Okay, let's back up.

 

Is the goal to have a universal external iLogic rule to change the parameters?

Are the part numbers based off of the assembly name?

 

If the answer to both of those questions are 'yes', then I think you can likely predict the file names and avoid using display names at all. Originally, you stated: "I can't call out the name directly because the rule has to work for multiple iams and we use distinct file names for all the sheet metal. "

 

I took that to mean you were creating iLogic "generators", and the most common way we deal with that type of set up is to stabilize the browser names in the assembly, so that when we "copy design" the assembly, the file names can be anything, and the ilogic just uses the common browser names.

 

But now I think I understand that your sheet metal parts have a typical naming scheme that can always be known by looking at the name of the active file (the assembly). If that's the case then something like this might work:

 

'get assembly name
'example: TK-DMES-021-019H36
oName = ThisDoc.FileName(False) 'false = without extension

'split the file name into an array
'using the dashes as the split char
oSplit = Split(oName, "-")

'assign each to a constant
oPrefix = oSplit(0) 'example: TK
oLetterCode = oSplit(1) 'example: DMES
oNumberCode1 = oSplit(2) 'example: 021
'format value to use only right 2 chars
oNumberCode1 = Right(oNumberCode1,2) 'example: 21
oNumberCode2 = oSplit(3) 'example: 019H36

'create arraylist with names of
'the components to process
'using the constants
Dim oComponentList As New ArrayList
oComponentList.add("T-PLT-" & oNumberCode1 & oLetterCode & ":1")
oComponentList.add("T-PLT-" & oNumberCode1 & oLetterCode & ":99")
oComponentList.add("B-PLT-" & oNumberCode1 & oLetterCode & ":1")
oComponentList.add("B-PLT-" & oNumberCode1 & oLetterCode & ":2")

'iterate through the
'components listed in the arraylist
For Each oItem In oComponentList

	Try 
		'try to get active status of the
		'component item, as a test to 
		'see if it exists
		oTest = Component.IsActive(oItem)
	Catch
		'catch error that occurs
		'when a component in the list
		'is not found
		'example: T-PLT-021DMES:99
		'example: B-PLT-021DMES:2
		Continue For
	End Try

	'push out parameters
	Parameter(oItem, "LNG") = LNG
	Parameter(oItem, "WTH") = WTH
	Parameter(oItem, "HGT") = HGT
	Parameter(oItem, "THK") = THK
Next

'Update
InventorVb.DocumentUpdate()

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Message 9 of 12
Anonymous
in reply to: Curtis_Waguespack

That would work perfect except our naming scheme changes when a standard tank is copied into a job. It becomes TK-(job #).

I think I'm still restricted to using either display name or browser name. 

 

As for external rule - everything falls apart when I tried that. Both my original parameter matching rule and your version set all the parameters in the tank and on the parts to 0 in. Then it stops updating. 

 

My plan was to use an external VBA we found which allows me to insert iLogic rules and set the event trigger on a group of files without opening them in the browser. Once the rule is inserted into the files, I use Task Scheduler to update and check in the modified files, again, without opening them in the browser. 

 

A work around, but much much much faster than opening each file and inserting manually. I used the same method already to add the Sheet_Metal rule to all our bulk steel files. You can see that rule on T-PLT-21DMES and B-PLT-21DMES

Message 10 of 12
Curtis_Waguespack
in reply to: Anonymous


@Anonymous wrote:

 

 

As for external rule - everything falls apart when I tried that. Both my original parameter matching rule and your version set all the parameters in the tank and on the parts to 0 in. Then it stops updating. 

 


Ahh, correct. In order to use this as an external rule you'll need to format the assembly parameter from just the variable name, such as LNG to Parameter("LNG"), as shown below:

 

 

	'push out parameters
	Parameter(oItem, "LNG") = Parameter("LNG")
	Parameter(oItem, "WTH") = Parameter("WTH")
	Parameter(oItem, "HGT") = Parameter("HGT")
	Parameter(oItem, "THK") = Parameter("THK")

 

Without the formatting the external rule reads LNG as  constant that has no value, or a value of zero I guess, and it pushes that to your part models, and then it's "gone all pear shaped".

 

So format the assembly parameters as shown and use external rules. If you push internal rules into a bunch of files, in 3 months you'll make improvements to the rules, and then a month later more improvements, and then over time you'll end up with 18 different versions of your rules floating around all over, and have no choice but to walk into heavy traffic just to end the madness.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 11 of 12
Curtis_Waguespack
in reply to: Anonymous


@Anonymous wrote:

That would work perfect except our naming scheme changes when a standard tank is copied into a job. It becomes TK-(job #).

 


Hi ascott_shipco,

 

So maybe I missed earlier when splitting the assembly name and using it. Can you just process the components that contain T-PLT- and B-PLT- as in this example?

 

Or maybe it's simpler yet, do you really just want to run this on every sheetmetal file? If so we can do that by looking at the component's document file sub-type.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)  

	If oOccurrence.Name.Contains("T-PLT-") _
	Or oOccurrence.Name.Contains("B-PLT-") Then

	'push out parameters
	Parameter(oOccurrence.Name, "LNG") = Parameter("LNG")
	Parameter(oOccurrence.Name, "WTH") = Parameter("WTH")
	Parameter(oOccurrence.Name, "HGT") = Parameter("HGT")
	Parameter(oOccurrence.Name, "THK") = Parameter("THK")
	
	End If
Next


'Update
InventorVb.DocumentUpdate()
Message 12 of 12
Anonymous
in reply to: Curtis_Waguespack

I added some "or" lines to encompass all our PLTs and put the "push out parameters" into a try catch statement so I could add all the driving parameters for different style tanks and it works great.

 

When the iam parameters were referenced as " LNG " the rule fired as soon as a parameter changed. Now that the parameters are referenced as Parameter("LNG") it won't fire until I tell it. Is there a way to make this automatic again? I thought the event trigger "Any Model Parameter Change" would force it to fire but it doesn't seem to work.

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report