Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
- Dim AcadApp As AcadApplication
- Dim appver, appverc As Object
- 'Getting Installed CAD Version through Registry
- appver = TryCast(My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Autodesk\AutoCAD", "CurVer", Nothing), Object)
- If appver Is Nothing Then
- 'MessageBox.Show("AutoCAD not installed !!")
- else
- appverc = appver.Substring(1, 2)
- End If
- 'Start the proccess
- 'First Check if AutoCAD [acad.exe] is running
- If IsProcessRunning("acad") Then
- Try
- 'Assign APP instances with installed version
- AcadApp = GetObject(, "AutoCAD.Application." + appverc.ToString())
- 'Set Active
- AcadApp.Visible = True
- AcadApp.WindowState = AcWindowState.acMax
- SET_ACAD_Active()
- '''CODE TO SEND COMMANDS VIA CAD EDITOR
- '' Dim AcDoc = AcadApp.ActiveDocument
- '' Dim command As String = "(alert ""x"" ) "
- '' AcDoc.SendCommand(command)
- ''GET POINTS
- Dim start As Object
- ''Using Editor ,get selected point's coordinates
- start = AcadApp.ActiveDocument.Utility.GetPoint(, "Select Point :")
- ''PROCCESS
- ''
- ''
- ''
- ''
- Catch ex As Exception
- MessageBox.Show("ERROR IN PROCCESS :: " + ex.ToString)
- End Try
- Else
- MessageBox.Show("AutoCAD IS NOT RUNNING")
- End If
- End Sub
- Public Function IsProcessRunning(ByVal name As String) As Boolean
- For Each clsProcess As Process In Process.GetProcesses()
- If clsProcess.ProcessName.StartsWith(name) Then
- Return True
- End If
- Next
- Return False
- End Function
- Sub SET_ACAD_Active()
- If IsProcessRunning("acad") Then
- Dim App As Process() = Process.GetProcessesByName("acad")
- If App.Length > 0 Then
- AppActivate(App(App.Length - 1).Id)
- End If
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement