Announcements

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

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: 

Dynamic form

11 REPLIES 11
Reply
Message 1 of 12
j.pavlicek
872 Views, 11 Replies

Dynamic form

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.
Labels (2)
11 REPLIES 11
Message 2 of 12
marcin_otręba
in reply to: j.pavlicek

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


   
Message 3 of 12
j.pavlicek
in reply to: marcin_otręba

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.
Message 4 of 12
marcin_otręba
in reply to: j.pavlicek

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


   
Message 5 of 12

we talk about ilogic, vba or addin ?

Hey, maybe you want to check my apps:

 


 ViewTools:                   DrawingTools:           MRU Folders:

 

ViewTools        DrawingTools         MRU Folders


   
Message 6 of 12
j.pavlicek
in reply to: marcin_otręba

iLogic or VBA



Inventor 2022, Windows 10 Pro
Sorry for bad English.
Message 7 of 12
marcin_otręba
in reply to: j.pavlicek

 

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


   
Message 8 of 12
j.pavlicek
in reply to: marcin_otręba

Dim lbl As Label

Compile error: User-defined type not defined

 

 



Inventor 2022, Windows 10 Pro
Sorry for bad English.
Message 9 of 12
marcin_otręba
in reply to: j.pavlicek

sorry this is for vba not ilogic.

Hey, maybe you want to check my apps:

 


 ViewTools:                   DrawingTools:           MRU Folders:

 

ViewTools        DrawingTools         MRU Folders


   
Message 10 of 12
j.pavlicek
in reply to: marcin_otręba

It was ran in VBA.

vba_snip01.png



Inventor 2022, Windows 10 Pro
Sorry for bad English.
Message 11 of 12
marcin_otręba
in reply to: j.pavlicek

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


   
Message 12 of 12
j.pavlicek
in reply to: marcin_otręba

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



Inventor 2022, Windows 10 Pro
Sorry for bad English.

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

Post to forums  

Autodesk Design & Make Report