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: 

Poperty Editor - Please review

15 REPLIES 15
Reply
Message 1 of 16
Anonymous
380 Views, 15 Replies

Poperty Editor - Please review

My iPropWiz quit some time ago and without any support to get it back up and running I generated my own, attached in .txt format.

It works great but it's a bit slow. Can someone that knows this stuff take a look and see if anything I've written into it can be changed to increase performance?

Edit : this is the form code, the module code contains a check to make sure it's not a drawing (models and assemblies only) and exits if it isn't, then of course it kicks off the form.

Thanks guys !

Eric Message was edited by: ebbuckner
15 REPLIES 15
Message 2 of 16
Anonymous
in reply to: Anonymous

I don't see anything obvious but since I don't have the form I can't run it
to see what's slow and possibly narrow down what to look at. Can you save
the form as a .frm file and post that?
--
Brian Ekins
Autodesk Inventor API
Message 3 of 16
Anonymous
in reply to: Anonymous

Here is the module code...
Message 4 of 16
Anonymous
in reply to: Anonymous

Couldn't post a .frm file so I zipped it up and here it is, thanks Brian, much appreaciated. There's also a .frx that was generated from the form export in there but I[m not sure what that is. form code?
Message 5 of 16
Anonymous
in reply to: Anonymous

I inserted your code into my project and ran it with an assembly I happened
to have open. I don't see any performance issues. It's basically
instantaneous. Both when I click "Apply" or "OK" to set the parameters and
when I initially open the dialog and it's reading the current property
values to display in the dialog. Is there some specific workflow where you
see performance issues?
--
Brian Ekins
Autodesk Inventor API
Message 6 of 16
Anonymous
in reply to: Anonymous

I see the lag inside the assemblies I am currently hip deep into, they are large though and I haven't had a chance to try it out on smaller ones.

Let me test that out and I'll get back to ya. Thanks Brian!

Eric
Message 7 of 16
Anonymous
in reply to: Anonymous

I tested it out inside some smaller assemblies and good to go. One question though, what would I add to allow the editor to work on parts/assy's that are being edited inside of assemblies. For example, I want to edit the properties of a part that is used inside of the assembly I have open. I double click or RMB the part and edit it inside the assembly but as it stands now the editor still shows the current properties of the assembly and edits them as well.

Thanks. You should know that I used a lot of your white papers in generating this and other code, very nice work!

Eric
Message 8 of 16
Anonymous
in reply to: Anonymous

Hi Eric,

I'm glad some the papers have helped.

When you have an assembly open it is the active document and the
ActiveDocument property of the application will return it. When you
in-place active a part or subassembly within that assembly, the top-level
assembly remains the active document. That's the reason for the problem
you're seeing.

What you need to do is use the ActiveEditObject property instead. If you've
in-place activated a part within the assembly this property will return the
PartDocument you're currently editing. However, you need to be a bit
careful with the ActiveEditObject property because it will return more than
just documents. For example if you in-place edit the part and then edit a
sketch within it, this property will return the sketch being edited. We
plan to introduce something else in the future to make this easier. I've
worked around this by writing the function below.

Private Function GetActiveEditDocument() As Document
' Check to make sure a document is active.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kNoDocument
Then
' Special case depending on what the active edit object is.
If TypeOf ThisApplication.ActiveEditObject Is Inventor.Document Then
' Return the document.
Set GetActiveEditDocument = ThisApplication.ActiveEditObject
ElseIf TypeOf ThisApplication.ActiveEditObject Is Sheet Then
Dim drawingSheet As Sheet
Set drawingSheet = ThisApplication.ActiveEditObject

' Get the parent document from the sheet.
Dim drawingDocument As drawingDocument
Set drawingDocument = drawingSheet.Parent

Set GetActiveEditDocument = drawingDocument
ElseIf TypeOf ThisApplication.ActiveEditObject Is DrawingSketch Then
' If a drawing sketch is active the parent drawing has to be
active so just return it.
Set GetActiveEditDocument = ThisApplication.ActiveDocument
ElseIf TypeOf ThisApplication.ActiveEditObject Is planarSketch Then
' A sketch in either a part or assembly document is active.
Dim planarSketch As planarSketch
Set planarSketch = ThisApplication.ActiveEditObject

Dim componentDefinition As componentDefinition
Set componentDefinition = planarSketch.Parent
Set GetActiveEditDocument = componentDefinition.Document
ElseIf TypeOf ThisApplication.ActiveEditObject Is flatPattern Then
Dim flatPattern As flatPattern
Set flatPattern = ThisApplication.ActiveEditObject

Set GetActiveEditDocument = flatPattern.Parent.Document
Else
MsgBox ("Unhandled active edit object type: " &
TypeName(ThisApplication.ActiveEditObject))
Set GetActiveEditDocument = Nothing
End If
Else
Set GetActiveEditDocument = Nothing
End If
End Function

--
Brian Ekins
Autodesk Inventor API
Message 9 of 16
Anonymous
in reply to: Anonymous

I added ....

If TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
MsgBox "May not run in Sketch Mode, please return and run PropEditor"
Exit Sub
End If

.... to the module code which works well and added ....

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveEditObject

.... to the form code.

Thanks Brian, works great. Now I need to force CAPS and make some fields mandatory and I'm set. really appreciate the help.

Eric
Message 10 of 16
Anonymous
in reply to: Anonymous

>Now I need to force CAPS

easy, for each textbox do

Private Sub TextBoxXXXX_Exit(ByVal Cancel As MSForms.ReturnBoolean)

TextBoxXXXX.Text = UCase(TextBoxXXXX.Text)

exit sub


This will change it to caps no matter what the user types.
Message 11 of 16
Anonymous
in reply to: Anonymous

You mean add this code (modifed to match the txtbox name) to each box?

For example, double clicking on the Part Number field brings up a new Private sub that looks like this...

Private Sub txtPartNumber_Change()

End Sub

Which should look like this after your treatment right?

Private Sub txtPartNumber_Exit(ByVal Cancel As MSForms.ReturnBoolean)

txtPartNumber.Text = UCase(txtPartNumber.Text)

End Sub
Message 12 of 16
Anonymous
in reply to: Anonymous

Yup, that must have been what you meant, guess I could have tried before I asked. Thanks again man!
Message 13 of 16
Anonymous
in reply to: Anonymous

Final addition was...

If Me.txtTitleLine1.Value = Empty Then
MsgBox "Title Line 1 Field Must Be Populated"
Exit Sub
End If

To a few of the mandatory fields. WoooHooo, all done!

thanks again!

Eric
Message 14 of 16
Anonymous
in reply to: Anonymous

Can you post the 'final' version ?
Message 15 of 16
Anonymous
in reply to: Anonymous

I'll try, I can't seem to attach anything just now.
Message 16 of 16
Anonymous
in reply to: Anonymous

Here you go.

The Module Code is as follows -
********************************************************
Public Sub PropEdit()

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

On Error Resume Next

If TypeOf ThisApplication.ActiveEditObject Is PlanarSketch Then
MsgBox "May not run in Sketch Mode, please return and run PropEditor"
Exit Sub
End If

If oDoc.DocumentType = kDrawingDocumentObject Then
MsgBox "Must be in an Assembly or Part Document to run the Property Editor!"
Exit Sub
End If

PropEditForm.Show vbModeless
End Sub

************************************************************

The form code looks like this -

************************************************************

Private Sub CancelBut_Click()
Unload Me
End Sub
Private Sub txtAssyDescription_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtAssyDescription.Text = UCase(txtAssyDescription.Text)
End Sub
Private Sub txtDesignedBy_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtDesignedBy.Text = UCase(txtDesignedBy.Text)
End Sub
Private Sub txtDrawingNumber_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtDrawingNumber.Text = UCase(txtDrawingNumber.Text)
End Sub
Private Sub txtDrawnBy_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtDrawnBy.Text = UCase(txtDrawnBy.Text)
End Sub
Private Sub txtMaterialDescription_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtMaterialDescription.Text = UCase(txtMaterialDescription.Text)
End Sub
Private Sub txtMFGPartNumber_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtMFGPartNumber.Text = UCase(txtMFGPartNumber.Text)
End Sub
Private Sub txtNotes_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtNotes.Text = UCase(txtNotes.Text)
End Sub
Private Sub txtPartNumber_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtPartNumber.Text = UCase(txtPartNumber.Text)
End Sub
Private Sub txtProject_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtProject.Text = UCase(txtProject.Text)
End Sub
Private Sub txtStockNumber_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtStockNumber.Text = UCase(txtStockNumber.Text)
End Sub
Private Sub txtTitle_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtTitle.Text = UCase(txtTitle.Text)
End Sub
Private Sub txtTitleLine1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtTitleLine1.Text = UCase(txtTitleLine1.Text)
End Sub
Private Sub txtTitleLine2_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtTitleLine2.Text = UCase(txtTitleLine2.Text)
End Sub
Private Sub txtTitleLine3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtTitleLine3.Text = UCase(txtTitleLine3.Text)
End Sub
Private Sub txtVendor_Exit(ByVal Cancel As MSForms.ReturnBoolean)
txtVendor.Text = UCase(txtVendor.Text)
End Sub

Private Sub UserForm_Initialize()

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveEditObject

On Error Resume Next

Dim oIVDesignInfo As PropertySet
Set oIVDesignInfo = oDoc.PropertySets.Item("Design Tracking Properties")

Dim oIVDocSumInfo As PropertySet
Set oIVDocSumInfo = oDoc.PropertySets.Item("Inventor Document Summary Information")

Dim oIVSumInfo As PropertySet
Set oIVSumInfo = oDoc.PropertySets.Item("Inventor Summary Information")

Dim oIVCustomSet As PropertySet
Set oIVCustomSet = oDoc.PropertySets.Item("Inventor User Defined Properties")

Dim oIVPartNumber As Property
Set oIVPartNumber = oIVDesignInfo.Item("Part Number")

Dim oIVDrawingNumber As Property
Set oIVDrawingNumber = oIVDocSumInfo.Item("Category")

Dim oIVNotes As Property
Set oIVNotes = oIVSumInfo.Item("Comments")

Dim oIVMaterialDesc As Property
Set oIVMaterialDesc = oIVSumInfo.Item("Subject")

Dim oIVTitle As Property
Set oIVTitle = oIVSumInfo.Item("Title")

Dim oIVRev As Property
Set oIVRev = oIVSumInfo.Item("Revision Number")

Dim oIVProject As Property
Set oIVProject = oIVDesignInfo.Item("Project")

Dim oIVCkBy As Property
Set oIVCkBy = oIVDesignInfo.Item("Checked By")

Dim oIVCkDate As Property
Set oIVCkDate = oIVDesignInfo.Item("Date Checked")

Dim oIVEngBy As Property
Set oIVEngBy = oIVDesignInfo.Item("Engr Approved By")

Dim oIVDateEng As Property
Set oIVDateEng = oIVDesignInfo.Item("Engr Date Approved")

Dim oIVMFGPN As Property
Set oIVMFGPN = oIVDesignInfo.Item("Catalog Web Link")

Dim oIVAssyDesc As Property
Set oIVAssyDesc = oIVDesignInfo.Item("Description")

Dim oIVVendor As Property
Set oIVVendor = oIVDesignInfo.Item("Vendor")

Dim oIVStN As Property
Set oIVStN = oIVDesignInfo.Item("Stock Number")

Dim oStrTL1 As Double
oStrTL1 = String(0, "TL1")

Dim oIVTL1 As Property
Set oIVTL1 = oIVCustomSet.Item("Description 1")
If Err.Number <> 0 Then
Call oIVCustomSet.Add(oStrTL1, "Description 1")
End If

Dim oStrTL2 As Double
oStrTL2 = String(0, "TL2")

Dim oIVTL2 As Property
Set oIVTL2 = oIVCustomSet.Item("Description 2")
If Err.Number <> 0 Then
Call oIVCustomSet.Add(oStrTL2, "Description 2")
End If

Dim oStrTL3 As Double
oStrTL3 = String(0, "TL3")

Dim oIVTL3 As Property
Set oIVTL3 = oIVCustomSet.Item("Description 3")
If Err.Number <> 0 Then
Call oIVCustomSet.Add(oStrTL3, "Description 3")
End If

Me.txtPartNumber.Text = oIVPartNumber.Value
Me.txtDrawingNumber.Text = oIVDrawingNumber.Value
Me.txtNotes.Text = oIVNotes.Value
Me.txtMaterialDescription = oIVMaterialDesc.Value
Me.txtTitle = oIVTitle.Value
Me.txtRevisionNumber = oIVRev.Value
Me.txtProject = oIVProject.Value
Me.txtDrawnBy = oIVCkBy.Value
Me.txtDateDrawn = oIVCkDate.Value
Me.txtDesignedBy = oIVEngBy.Value
Me.txtDateDesigned = oIVDateEng.Value
Me.txtMFGPartNumber = oIVMFGPN.Value
Me.txtAssyDescription = oIVAssyDesc.Value
Me.txtVendor = oIVVendor.Value
Me.txtStockNumber = oIVStN.Value
Me.txtTitleLine1 = oIVTL1.Value
Me.txtTitleLine2 = oIVTL2.Value
Me.txtTitleLine3 = oIVTL3.Value

End Sub

Private Sub Concatenate_Click()
Me.txtNotes.Value = Me.txtTitleLine1 & " " & Me.txtTitleLine2 & " " & Me.txtTitleLine3
End Sub

Private Sub Today_Click()
Me.txtDateDrawn.Value = Now()
End Sub

Private Sub Today2_Click()
Me.txtDateDesigned.Value = Now()
End Sub

Private Sub AllpyBut_Click()

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveEditObject

Dim oIVDesignInfo As PropertySet
Set oIVDesignInfo = oDoc.PropertySets.Item("Design Tracking Properties")

Dim oIVDocSumInfo As PropertySet
Set oIVDocSumInfo = oDoc.PropertySets.Item("Inventor Document Summary Information")

Dim oIVSumInfo As PropertySet
Set oIVSumInfo = oDoc.PropertySets.Item("Inventor Summary Information")

Dim oIVCustomSet As PropertySet
Set oIVCustomSet = oDoc.PropertySets.Item("Inventor User Defined Properties")

Dim oIVPartNumber As Property
Set oIVPartNumber = oIVDesignInfo.Item("Part Number")

Dim oIVDrawingNumber As Property
Set oIVDrawingNumber = oIVDocSumInfo.Item("Category")

Dim oIVNotes As Property
Set oIVNotes = oIVSumInfo.Item("Comments")

Dim oIVMaterialDesc As Property
Set oIVMaterialDesc = oIVSumInfo.Item("Subject")

Dim oIVTitle As Property
Set oIVTitle = oIVSumInfo.Item("Title")

Dim oIVRev As Property
Set oIVRev = oIVSumInfo.Item("Revision Number")

Dim oIVProject As Property
Set oIVProject = oIVDesignInfo.Item("Project")

Dim oIVCkBy As Property
Set oIVCkBy = oIVDesignInfo.Item("Checked By")

Dim oIVCkDate As Property
Set oIVCkDate = oIVDesignInfo.Item("Date Checked")

Dim oIVEngBy As Property
Set oIVEngBy = oIVDesignInfo.Item("Engr Approved By")

Dim oIVDateEng As Property
Set oIVDateEng = oIVDesignInfo.Item("Engr Date Approved")

Dim oIVMFGPN As Property
Set oIVMFGPN = oIVDesignInfo.Item("Catalog Web Link")

Dim oIVAssyDesc As Property
Set oIVAssyDesc = oIVDesignInfo.Item("Description")

Dim oIVVendor As Property
Set oIVVendor = oIVDesignInfo.Item("Vendor")

Dim oIVStN As Property
Set oIVStN = oIVDesignInfo.Item("Stock Number")

Dim oIVTL1 As Property
Set oIVTL1 = oIVCustomSet.Item("Description 1")

Dim oIVTL2 As Property
Set oIVTL2 = oIVCustomSet.Item("Description 2")

Dim oIVTL3 As Property
Set oIVTL3 = oIVCustomSet.Item("Description 3")

oIVPartNumber.Value = Me.txtPartNumber.Value
oIVDrawingNumber.Value = Me.txtDrawingNumber.Value
oIVNotes.Value = Me.txtNotes.Value
oIVMaterialDesc.Value = Me.txtMaterialDescription.Value
oIVTitle.Value = Me.txtTitle.Value
oIVRev.Value = Me.txtRevisionNumber.Value
oIVProject.Value = Me.txtProject.Value
oIVCkBy.Value = Me.txtDrawnBy.Value
oIVCkDate.Value = Me.txtDateDrawn.Value
oIVEngBy.Value = Me.txtDesignedBy.Value
oIVDateEng.Value = Me.txtDateDesigned.Value
oIVMFGPN.Value = Me.txtMFGPartNumber.Value
oIVAssyDesc.Value = Me.txtAssyDescription.Value
oIVVendor.Value = Me.txtVendor.Value
oIVStN.Value = Me.txtStockNumber.Value
oIVTL1.Value = Me.txtTitleLine1.Value
oIVTL2.Value = Me.txtTitleLine2.Value
oIVTL3.Value = Me.txtTitleLine3.Value


End Sub

Private Sub OKBut_Click()

Dim oDoc As Document
Set oDoc = ThisApplication.ActiveEditObject

Dim oIVDesignInfo As PropertySet
Set oIVDesignInfo = oDoc.PropertySets.Item("Design Tracking Properties")

Dim oIVDocSumInfo As PropertySet
Set oIVDocSumInfo = oDoc.PropertySets.Item("Inventor Document Summary Information")

Dim oIVSumInfo As PropertySet
Set oIVSumInfo = oDoc.PropertySets.Item("Inventor Summary Information")

Dim oIVCustomSet As PropertySet
Set oIVCustomSet = oDoc.PropertySets.Item("Inventor User Defined Properties")

Dim oIVPartNumber As Property
Set oIVPartNumber = oIVDesignInfo.Item("Part Number")

Dim oIVDrawingNumber As Property
Set oIVDrawingNumber = oIVDocSumInfo.Item("Category")

Dim oIVNotes As Property
Set oIVNotes = oIVSumInfo.Item("Comments")

Dim oIVMaterialDesc As Property
Set oIVMaterialDesc = oIVSumInfo.Item("Subject")

Dim oIVTitle As Property
Set oIVTitle = oIVSumInfo.Item("Title")

Dim oIVRev As Property
Set oIVRev = oIVSumInfo.Item("Revision Number")

Dim oIVProject As Property
Set oIVProject = oIVDesignInfo.Item("Project")

Dim oIVCkBy As Property
Set oIVCkBy = oIVDesignInfo.Item("Checked By")

Dim oIVCkDate As Property
Set oIVCkDate = oIVDesignInfo.Item("Date Checked")

Dim oIVEngBy As Property
Set oIVEngBy = oIVDesignInfo.Item("Engr Approved By")

Dim oIVDateEng As Property
Set oIVDateEng = oIVDesignInfo.Item("Engr Date Approved")

Dim oIVMFGPN As Property
Set oIVMFGPN = oIVDesignInfo.Item("Catalog Web Link")

Dim oIVAssyDesc As Property
Set oIVAssyDesc = oIVDesignInfo.Item("Description")

Dim oIVVendor As Property
Set oIVVendor = oIVDesignInfo.Item("Vendor")

Dim oIVStN As Property
Set oIVStN = oIVDesignInfo.Item("Stock Number")

Dim oIVTL1 As Property
Set oIVTL1 = oIVCustomSet.Item("Description 1")

Dim oIVTL2 As Property
Set oIVTL2 = oIVCustomSet.Item("Description 2")

Dim oIVTL3 As Property
Set oIVTL3 = oIVCustomSet.Item("Description 3")

If Me.txtTitleLine1.Value = Empty Then
MsgBox "Title Line 1 Field Must Be Populated"
Exit Sub
End If

If Me.txtTitleLine2.Value = Empty Then
MsgBox "Title Line 2 Field Must Be Populated"
Exit Sub
End If

If Me.txtNotes.Value = Empty Then
MsgBox "Notes Field Must Be Populated"
Exit Sub
End If

If Me.txtStockNumber.Value = Empty Then
MsgBox "Stock Number Field Must Be Populated"
Exit Sub
End If

If Me.txtVendor.Value = Empty Then
MsgBox "Vendor Field Must Be Populated"
Exit Sub
End If

If Me.txtMFGPartNumber.Value = Empty Then
MsgBox "MFG PN Field Must Be Populated"
Exit Sub
End If

oIVPartNumber.Value = Me.txtPartNumber.Value
oIVDrawingNumber.Value = Me.txtDrawingNumber.Value
oIVNotes.Value = Me.txtNotes.Value
oIVMaterialDesc.Value = Me.txtMaterialDescription.Value
oIVTitle.Value = Me.txtTitle.Value
oIVRev.Value = Me.txtRevisionNumber.Value
oIVProject.Value = Me.txtProject.Value
oIVCkBy.Value = Me.txtDrawnBy.Value
oIVCkDate.Value = Me.txtDateDrawn.Value
oIVEngBy.Value = Me.txtDesignedBy.Value
oIVDateEng.Value = Me.txtDateDesigned.Value
oIVMFGPN.Value = Me.txtMFGPartNumber.Value
oIVAssyDesc.Value = Me.txtAssyDescription.Value
oIVVendor.Value = Me.txtVendor.Value
oIVStN.Value = Me.txtStockNumber.Value
oIVTL1.Value = Me.txtTitleLine1.Value
oIVTL2.Value = Me.txtTitleLine2.Value
oIVTL3.Value = Me.txtTitleLine3.Value



Unload Me

End Sub

***********************************************************

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

Post to forums  

Autodesk Design & Make Report