Open parts from assembly having only specific user parameter and change the parameter values and save then close

Open parts from assembly having only specific user parameter and change the parameter values and save then close

pranaykapse1
Contributor Contributor
443 Views
5 Replies
Message 1 of 6

Open parts from assembly having only specific user parameter and change the parameter values and save then close

pranaykapse1
Contributor
Contributor

I want to open parts or component occurrences in a separate window from the assembly having only a specific user parameter (let's say "Pipe_Standatd") and change the parameter values("Pipe_Standatd=ASME") and save it then close that part.

please help me with the logic code.

 

0 Likes
444 Views
5 Replies
Replies (5)
Message 2 of 6

bradeneuropeArthur
Mentor
Mentor

Do you have some more details?

Maybe some screenshots about what you mean?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 6

A.Acheson
Mentor
Mentor

You should be able to do this without opening the part. The part is all ready open in the context of the assembly. 

 

  'Get the active assembly.
    Dim AsmDoc As AssemblyDocument = ThisDoc.Document

    'Get the assembly component definition.
    Dim AsmDef As AssemblyComponentDefinition = AsmDoc.ComponentDefinition

    'Get all of the leaf occurrences of the assembly.
    Dim LeafOccs As ComponentOccurrencesEnumerator = AsmDef.Occurrences.AllLeafOccurrences

    'Iterate through the occurrences and print the name.
    For Each Occ As ComponentOccurrence In LeafOccs
		Dim occDef As PartComponentDefinition = Occ.Definition
		Dim OccDoc As PartDocument = occDef.Document
		
		If  OccDoc.IsModifiable Then
			Logger.Info(Occ.Name)
			occDef.Parameters.Item("Pipe_Standard").Value = "ASME"
		End If
    Next

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 4 of 6

pranaykapse1
Contributor
Contributor
Some of the external rules are not running without opening in a separate window.
is it possible to change the user parameter values using the VBA editor?
0 Likes
Message 5 of 6

pranaykapse1
Contributor
Contributor
I want to change the same user parameter value(say "Pipe_Standatd= ASME") to a lot of parts from the same assembly.
It is perfectly working by using the below logic rule.

Dim oAsmDoc As AssemblyDocument = ThisDoc.Document
For Each oOcc As ComponentOccurrence In oAsmDoc.ComponentDefinition.Occurrences
Try
Parameter(oOcc.Name, "Pipe_Standatd") =ASME
Catch
'null
End Try
Next

But some of the parts are dependent on external rules so they do not work properly without opening in a separate window.
So I need some logic rule to change user parameter( "Pipe_Standatd") value to ASME .
Process should be :
-> open the parts having "Pipe_Standatd" in separate window.
-> then do change the value of user paramer to "ASME".
-> save the file.
-> close.
Is it possible using VBA editor ?
0 Likes
Message 6 of 6

A.Acheson
Mentor
Mentor

In your initial post you mention ilogic and external rules. Why would you want to use VBA?

 

Can you please post the whole workflow including what the rules will be doing. The process is not clear. 

 

With document found from occurrence you can open the occuurence in its own document.

From API help under documents

 

Dim ActiveDoc As Document = ThisApplication.Documents.OpenFullDocumentName As String, [OpenVisible] As Boolean ) As Document

 

'DO SOMETHING WITH DOCUMENT 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes