Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to be able to save and replace and add a reference from previous component to new one. Right now it works but only if i select new component after the save and replace. Can someone help me code this correctly to allow the code to do this all in one go?
Thank you!
Imports Inventor
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports System.Windows.Forms
ThisApplication.ScreenUpdating = True
iLogicVb.Automation.RulesOnEventsEnabled = True
ThisApplication.SilentOperation = False
SendKeys.SendWait("{ESC}")
AppActivate(ThisApplication.Caption)
On Error Resume Next
Dim selectCmd As ControlDefinition
selectCmd = ThisApplication.CommandManager.ControlDefinitions.Item("AppContextual_CancelCmd")
selectCmd.Execute
P = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select component to replace")
Dim odoc As Document = P.Definition.Document
modelName = IO.Path.GetFileName(odoc.DisplayName)
Dim saveme As String
saveme = iProperties.Value(modelName, "Project", "Part Number")
'MsgBox(saveme)
ThisApplication.CommandManager.DoSelect(P)
Dim cm As CommandManager = ThisApplication.CommandManager
Dim cds As ControlDefinitions = cm.ControlDefinitions
Dim cd As ControlDefinition = cds("AssemblyBonusTools_SaveAndReplaceComponentCmd")
Call cd.Execute
M = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select component that you just replaced again to add reference")
Dim odoc1 As Document = M.Definition.Document
modelName1 = IO.Path.GetFileName(odoc1.DisplayName)
t = "Ref. Number"
'Try : x = iProperties.Value(modelName1,"Custom", t) : Catch : iProperties.Value(modelName1,"Custom", t) = "" : End Try
If iProperties.Value(modelName1, "Custom", t) = Nothing Then
myparam = InputBox("Reference Drawing Number:", t, "REF: " & saveme)
Else
myparam = InputBox("Reference Drawing Number:", t, "REF: " & saveme)
End If
iProperties.Value(modelName1, "Custom", t) = myparam
'MsgBox(iProperties.Value(modelName1, "Custom", t))
InventorVb.DocumentUpdate()
Solved! Go to Solution.