Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

5 REPLIES 5
Reply
Message 1 of 6
pranaykapse1
305 Views, 5 Replies

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

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.

 

5 REPLIES 5
Message 2 of 6

Do you have some more details?

Maybe some screenshots about what you mean?

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 3 of 6
A.Acheson
in reply to: pranaykapse1

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
Message 4 of 6
pranaykapse1
in reply to: A.Acheson

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?
Message 5 of 6

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 ?
Message 6 of 6
A.Acheson
in reply to: pranaykapse1

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

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

Post to forums  

Autodesk Design & Make Report