Message 1 of 5
ILOGIC - ThisApplication.ActiveView - push value into active view Iproperty

Not applicable
11-28-2018
02:09 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I like to manually set component part numbers which I use for parts list and ballooning and usually do this through the BOM. However sometimes when first laying out a multi-sheet drawing, I'd like to simply select a drawing view and enter the part number or description on the fly.
I've cobbled together some iLogic but it seems to be tripping up with ThisApplication.ActiveView. Can someone please review my rule and tell me what I am doing wrong? Thanks!
SyntaxEditor Code Snippet
'Exit if not drawing document Sub Main() If Not ThisApplication.ActiveDocument.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then Messagebox.Show("Current document is not drawing docuemnt", "Inventor") Exit Sub End If 'Prompt for new part number and description Dim oPartnumber As String oPartnumber = InputBox("Enter new part number", "Update part number") Dim oDescription As String oDescription = InputBox("Enter new description", "Update description") 'Access the currently active view Dim oView As DrawingView oView = ThisApplication.ActiveView oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName="" oModelName = oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName 'get file type and append to referenced document name oViewModelType = oView.ReferencedDocumentDescriptor.ReferencedDocument If oViewModelType.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then oModelName = oModelName + ".ipt" Else If oViewModelType.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then oModelName = oModelName + ".iam" Else oModelName = oModelName + ".ipn" End If 'update the component properties with new values Try iProperties.Value(oModelName, "Project", "Part Number") = oPartnumber iProperties.Value(oModelName, "Project", "Description") = oDescription InventorVb.DocumentUpdate() Catch 'do nothing if error End Try End Sub