frostrap Posted May 16, 2008 Share Posted May 16, 2008 Hello gurus, I'm writing a block manager program in VBA and there seems to be this bug where the filedia variable in AutoCAD is getting set to 0. The problem is that nowhere in the code do I reference the filedia variable, so I have no idea what it is that is changing the value of this variable. In one portion of the program I am calling the insert command using the follwing code (This is the only place in the project where I am initiating an autocad command using sendcommand): ThisDrawing.SendCommand "-insert" & vbCr & thePath & vbCr & "S" & vbCr & theScale & vbCr (I chose to insert the block this way rather than programatically because I wanted the user to be able to see a preview of the image on screen as they were selecting the insertion point and rotation.) Is this possibly the cause of the filedia issue? Has this problem come about for anyone else? Ideas? Thanks, Joe Quote Link to comment Share on other sites More sharing options...
LCE Posted May 16, 2008 Share Posted May 16, 2008 Can you please post the full code. Obviously, it is not in the code that you posted, so it may be elsewhere. Are you calling any lisp routines, or could this be from something entirely seperate from your app? Quote Link to comment Share on other sites More sharing options...
frostrap Posted May 16, 2008 Author Share Posted May 16, 2008 There's quite a bit of code (about 1500 lines), so I don't think posting all of the code is going to happen. I'm not calling any lisp routines. The only think I'm doing that issues control away from VBA is the insert thing I posted above where control is passed to the autocad command prompt momentarily. Here's the code for the sub that contains the insert command: Sub InsertBlock(Optional thePath As String) Dim theScale As Variant 'set the dimscale If IsNumeric(UserForm1.TextBox1.Value) = False Or UserForm1.TextBox1.Value < 0 Then MsgBox "Please entera valid numeric default scale value." UserForm1.TextBox1.SetFocus Exit Sub End If If UserForm1.TextBox1.Value = 0 Then theScale = ThisDrawing.GetVariable("DIMSCALE") Else theScale = UserForm1.TextBox1.Value End If Dim objLayer As AcadLayer Dim FoundLayer As Boolean Dim OldLayer As String 'determine whether or not default layer exists 'if it does exist, set it as current layer 'if it doesn't exist, prompt the user and return to the userform. FoundLayer = False For Each objLayer In ThisDrawing.Layers If objLayer.Name = UserForm1.ComboBox1.Value Then FoundLayer = True Exit For End If Next If FoundLayer = False Then MsgBox "The default layer entered for this block does not exist on this drawing." UserForm1.ComboBox1.SetFocus Exit Sub Else OldLayer = ThisDrawing.ActiveLayer.Name ThisDrawing.ActiveLayer = ThisDrawing.Layers(UserForm1.ComboBox1.Value) End If If thePath = "" Then thePath = GetDefaultDirectory + UserForm1.ListBox1.Value + "\" + UserForm1.ListBox2.Value + ".dwg" End If UserForm1.Hide 'insert with or without dynamic rotation If UserForm1.CheckBox2 = True Then ThisDrawing.SendCommand "-insert" & vbCr & thePath & vbCr & "S" & vbCr & theScale & vbCr Else ThisDrawing.SendCommand "-insert" & vbCr & thePath & vbCr & "S" & vbCr & theScale & vbCr & "R" & vbCr & "0" & vbCr End If 'expload last block entered If UserForm1.CheckBox3.Value = True Then ThisDrawing.SendCommand "Explode" & vbCr & "L" & vbCr & vbCr End If 'reset the original layer ThisDrawing.ActiveLayer = ThisDrawing.Layers(OldLayer) End Sub I can't be certain that the problem isn't coming from somewhere else, but I do know that no other VBA programs are running when this happens, and this problem never seemed to occur prior to writing this program. There are a few other subs that I have that are reading and writing information from a text file, though I doubt that's where the problem is. Quote Link to comment Share on other sites More sharing options...
NBC Posted May 16, 2008 Share Posted May 16, 2008 Hello gurus, I'm writing a block manager program in VBA and there seems to be this bug where the filedia variable in AutoCAD is getting set to 0. The problem is that nowhere in the code do I reference the filedia variable, so I have no idea what it is that is changing the value of this variable. In one portion of the program I am calling the insert command using the follwing code (This is the only place in the project where I am initiating an autocad command using sendcommand): ThisDrawing.SendCommand "-insert" & vbCr & thePath & vbCr & "S" & vbCr & theScale & vbCr (I chose to insert the block this way rather than programatically because I wanted the user to be able to see a preview of the image on screen as they were selecting the insertion point and rotation.) Is this possibly the cause of the filedia issue? Has this problem come about for anyone else? Ideas? Thanks, Joe Hi Joe, the reason your dialogue box is being suppressed is because you are using the command line version of insert; ie. you are using -insert, instead of insert. Notice the minus sign at the beginning of your command. The minus sign when used at the beginning of command tells the command to use the command line only. Quote Link to comment Share on other sites More sharing options...
frostrap Posted May 16, 2008 Author Share Posted May 16, 2008 That is what I suspected. The use of the command line version is intentional, as it is the only way that I know of to programatically interface with portions of the insert command while allowing other portions of the command to remain user controlled. For instance, I wanted to programatically set the x y and z scales, but i want the user to be able to choose the rotation dynamically on screen. Do you know of any way to accomplish this without using sendcommand "-insert"...? Quote Link to comment Share on other sites More sharing options...
Rankine16 Posted April 13, 2009 Share Posted April 13, 2009 I am having a problem when FILEDIA is set to 1 and the pulldown still won't work. When I click on FILE then OPEN, the toolbars ghost out and nothing happens. At the command line it says "_open" but does nothing. The same thing happens when I click on the open button. I have changed both FILEDIA and CMDDIA to and from 0 to 1, closing AutoCAD and completely rebooting and still nothing. With FILEDIA set to 0 I can type the file name, but set to 1 won't launch the dialog box. Quote Link to comment Share on other sites More sharing options...
CmdrDuh Posted April 13, 2009 Share Posted April 13, 2009 that sounds like your dialog box is floating off screen, and its just not visable. Try hitting alt-enter or alt-space and choosing move, hit the arrow keys once or twice, then move your mouse to the middle of your screen and see if your dialog box is moving Quote Link to comment Share on other sites More sharing options...
Rankine16 Posted April 13, 2009 Share Posted April 13, 2009 That did it! Thank you very much. I work with two monitors and the problem started when one of them went down. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.