Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Dynamic form

j.pavlicek
Collaborator
Collaborator

Dynamic form

j.pavlicek
Collaborator
Collaborator

Hello,
I want to handle some (Custom) iProperties of all assembly components from one place and need to find reasonable solution.

 

I want to set Custom iPropery (name it for example: "Parent assembly number") for each component in an assembly. Based on the assembly iProperty "Number". BUT do it automatically only when is initial state of "Parent assembly number" empty.

 

If there are some value, user has to decide what to do (keep initial value, use automatic value as when empty, manually written value).

 

It could be possibly done with MsgBox/InputBox, but it becomes crazy in case of large assembly. I wonder is possible to read create "dynamic form" where one row will be generated for every component (which meets criteria). Something like image below.


 form01.png

 

I tried to search for solution, but I don't even know what phrase to search to get relevant results.

 

Thanks for advice!



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes
Reply
872 Views
11 Replies
Replies (11)

marcin_otręba
Advisor
Advisor

hi,

 

why you need form ? just check if subpart property value is empty, not emty, different of or equal to paren property:

maybe something like this?:

Dim doc As Document
Dim ass As AssemblyDocument = ThisDoc.Document
For Each doc In ass.AllReferencedDocuments
	Select Case doc.PropertySets.Item(4).Item("Number").Value
	Case ""
		Try
			
		doc.PropertySets.Item(4).Item("Number").Value = ass.PropertySets.Item(4).Item("Number").Value
		Catch
			doc.PropertySets.Item(4).Add(ass.PropertySets.Item(4).Item("Number").Value,"Number")
		End Try
	
	
	Case Not "Parent assembly number"
		Try
			
		doc.PropertySets.Item(4).Item("Number").Value = ass.PropertySets.Item(4).Item("Number").Value
		Catch
			doc.PropertySets.Item(4).Add(ass.PropertySets.Item(4).Item("Number").Value,"Number")
		End Try
		
End Select		
Next

 

Hey, maybe you want to check my apps:

 


 ViewTools:                   DrawingTools:           MRU Folders:

 

ViewTools        DrawingTools         MRU Folders


   
0 Likes

j.pavlicek
Collaborator
Collaborator

Checking is not problem for me. I'm capable to do it.

 

I need the user input. For example there is assembly with 200 components, almost all have desired iProperty empty, but some of them (in the original post Components 01, 02, 10, 12, 99) have <initial_value> there. This need to be reviewed by user.

 

I want to show them in single form where could be edited. My problem is that row count in the form could be between 0 to Document.AllReferencedDocuments.Count, so I need to generate this form dynamically.



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes

marcin_otręba
Advisor
Advisor

You can use DataGridView, and set two last column as button.

You can use :

 

dataGridView1.Rows.Add(component name, value)

https://forums.autodesk.com/t5/inventor-customization/using-a-datagridview-control-in-vba-or-ilogic/...

 

Hey, maybe you want to check my apps:

 


 ViewTools:                   DrawingTools:           MRU Folders:

 

ViewTools        DrawingTools         MRU Folders


   
0 Likes

marcin_otręba
Advisor
Advisor

we talk about ilogic, vba or addin ?

Hey, maybe you want to check my apps:

 


 ViewTools:                   DrawingTools:           MRU Folders:

 

ViewTools        DrawingTools         MRU Folders


   
0 Likes

j.pavlicek
Collaborator
Collaborator

iLogic or VBA



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes

marcin_otręba
Advisor
Advisor

 

Private Sub UserForm_Activate()

i = 1
Dim doc As Document
Dim ass As AssemblyDocument
Set ass = ThisApplication.ActiveDocument
For Each doc In ass.AllReferencedDocuments
               Dim lbl As Label
                Set lbl = UserForm1.Controls.Add("forms.label.1")
                lbl.Caption = doc.PropertySets.Item(3).Item("part number").Name
                lbl.Top = 5 + (i * 20) - 1
                lbl.Left = 10
                lbl.WordWrap = False
                lbl.AutoSize = True
                Set tbox = UserForm1.Controls.Add("forms.textbox.1")
                tbox.Text = doc.PropertySets.Item(3).Item("part number").Value
                tbox.Top = 5 + (i * 20) - 2
                tbox.Left = 140
                tbox.Width = 100
         Dim but As CommandButton
                Set but = UserForm1.Controls.Add("forms.commandbutton.1")
                but.Caption = "reset"
                but.Top = 5 + (i * 20) - 2
                but.Left = 280
                but.Width = 50
 Set but = UserForm1.Controls.Add("forms.commandbutton.1")
                but.Caption = "ok"
                but.Top = 5 + (i * 20) - 2
                but.Left = 340
                but.Width = 50
                 i = i + 1
Next

End Sub

 

Hey, maybe you want to check my apps:

 


 ViewTools:                   DrawingTools:           MRU Folders:

 

ViewTools        DrawingTools         MRU Folders


   
0 Likes

j.pavlicek
Collaborator
Collaborator
Dim lbl As Label

Compile error: User-defined type not defined

 

 



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes

marcin_otręba
Advisor
Advisor

sorry this is for vba not ilogic.

Hey, maybe you want to check my apps:

 


 ViewTools:                   DrawingTools:           MRU Folders:

 

ViewTools        DrawingTools         MRU Folders


   
0 Likes

j.pavlicek
Collaborator
Collaborator

It was ran in VBA.

vba_snip01.png



Inventor 2022, Windows 10 Pro
Sorry for bad English.

marcin_otręba
Advisor
Advisor

do you have all references and form in your project?

marcin_otręba_1-1590062517246.png

 

Hey, maybe you want to check my apps:

 


 ViewTools:                   DrawingTools:           MRU Folders:

 

ViewTools        DrawingTools         MRU Folders


   
0 Likes

j.pavlicek
Collaborator
Collaborator

It's working now, Forms Library was missing. Thank you.



Inventor 2022, Windows 10 Pro
Sorry for bad English.
0 Likes