Jump to content

vb code to open drawings in autocad lt


Recommended Posts

Posted

i have autocad2007 and autocad LT 2006 in my system i want to open dwg files in autccad Lt 2006 using vb.6 code.

 

i want to modify the above code and open dwg drawings in Lt

else looking for suitable vb.6 code

 

Dim DwgName As String
       On Error Resume Next
       Set acadApp = GetObject(, "AutoCAD.Application")

       If Err Then
           Set acadApp = CreateObject("AutoCAD .Application")
           Err.Clear
       End If
'        If Right(App.Path, 1) = "\" Then
'            DwgName = "C:\13027167-GX2.dwg"
'        Else
'            DwgName = "C:\13027167-GX2.dwg"
'        End If
       Set acadDoc = acadApp.ActiveDocument
       If acadDoc.FullName <> DwgName Then
           acadDoc.Open DwgName
       End If
       Dim str As String, str1 As String
       str1 = "_-insert" & vbLf & """" & "C:\14001120-AA8232-AC8232-AZ665.dwg" & """" & vbLf & "0,0,0" & vbLf & vbLf & vbLf & vbLf & "z" & vbLf & "a" & vbLf
       'str = "dwin" & vbLf
       acadDoc.SendCommand str1
      ' acadDoc.SendCommand str

       acadApp.Visible = True


Posted

I do not believe the LT version can be accessed with VB in it's present state.

Posted

That's right. You have no COM interface in LT, so you have nothing like

 

Set acadLTApp = CreateObject("AutoCADLT.Application")

 

You can get lisp in LT with LT-Extender.

You can "run" a dwg file in Windows with VB, this will open it in LT if you have the file association.

Posted

i do agree but if u have only LT or autocad 2007 in system then this shell command can be used to open the drawing

 

but i want to pass some values in command line which i dotn know how to do it in lt

 

Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
                   ByVal hwnd As Long, _
                   ByVal lpOperation As String, _
                   ByVal lpFile As String, _
                   ByVal lpParameters As String, _
                   ByVal lpDirectory As String, _
                   ByVal nShowCmd As Long) As Long

Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_SHOWMAXIMIZED As Long = 3
Private Const SW_SHOWMINIMIZED As Long = 2

Private Sub Command1_Click()
   ShellExecute Me.hwnd, "open", "C:\Users\Public\Test1.dwg", vbNullString, "C:\", SW_SHOWNORMAL
End Sub

Posted

where can i get LT-Extender. is it free version?

Posted

hello Ragnar Thor

 

i have downloaded briscad trail version

 

ple help me out with vb.6 code to open and also to inset dwg drawings

 

regards

sam

Posted

It is almost the same as for AUtoCAD.

For example:

 

   Dim bcad As AcadApplication
   Dim I As Integer
   On Error Resume Next
Retry:   'In case Bricscad is closing down
   Set bcad = GetObject("", "BricscadApp.AcadApplication")
   If Err = -2147023179 Then
       I = I + 1
       Err.Clear
       If I > 1000 Then Exit Function
       GoTo Retry
   Set bcad = CreateObject("BricscadApp.AcadApplication")
   End If
   bcad.Visible = True

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...