Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.
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.
I tried to search for solution, but I don't even know what phrase to search to get relevant results.
Thanks for advice!
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
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.
You can use DataGridView, and set two last column as button.
You can use :
dataGridView1.Rows.Add(component name, value)
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
Dim lbl As Label
Compile error: User-defined type not defined
It's working now, Forms Library was missing. Thank you.
Can't find what you're looking for? Ask the community or share your knowledge.