dbroada Posted April 20, 2010 Share Posted April 20, 2010 How do I add an existing block object into a drawing using VBA? If the block is already defined in the drawing a simple Set BlockRefObj = ThisDrawing.ModelSpace.InsertBlock(TriPos, "Tri", CScale, CScale, CScale, 0) will insert the block I want. However my routine doesn't work if my block is only defined on the network. I can -INSERT Tri to show that it can be found but my routine just gives me a "File error" message. I'm guessing I have to add the block into the block collection but I can't find how to add one from a .dwg file. Any pointers? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 20, 2010 Share Posted April 20, 2010 When using the InsertBlock method in VL, if the block is not in the support path, you must supply the full path that the block resides at. I would assume this would be the same for VBA. Quote Link to comment Share on other sites More sharing options...
dbroada Posted April 20, 2010 Author Share Posted April 20, 2010 That's what I thought too but I get still get a File error with Set BlockRefObj = ThisDrawing.ModelSpace.InsertBlock(TriPos, "P:\Design_Office\DO_Admin\symbols\miscellaneous\Tri.DWG", CScale, CScale, CScale, 0) What is REALLY annoying me is that it used to work without any path but our network has been "rearranged" and it no longer works either with or without the full path being given. GGRRRRRR Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 20, 2010 Share Posted April 20, 2010 Double Backslashes? Quote Link to comment Share on other sites More sharing options...
dbroada Posted April 20, 2010 Author Share Posted April 20, 2010 not usually in VBA hey that worked! Lets try again. ######## inconsistant or what? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 20, 2010 Share Posted April 20, 2010 not usually in VBA hey that worked! Lets try again. ######## inconsistant or what? I thought escape characters were in all languages - but glad you got it working Quote Link to comment Share on other sites More sharing options...
dbroada Posted April 20, 2010 Author Share Posted April 20, 2010 only working sometimes - REALLY frustrating! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 20, 2010 Share Posted April 20, 2010 only working sometimes - REALLY frustrating! You still receive the file error? I'm out of ideas - I can only get that method to fail if the block cannot be found. Quote Link to comment Share on other sites More sharing options...
dbroada Posted April 21, 2010 Author Share Posted April 21, 2010 I really couldn't get this sorted. I still can't find a way of getting an ,dwg file into my drawing without encountering a file error message. The routine that was causing the problem inserted a simple attributed issue triangle block so I have created the block from scratch within the routine. At least I now know it is available each time the routine is run. Quote Link to comment Share on other sites More sharing options...
Lt Dan's legs Posted May 14, 2010 Share Posted May 14, 2010 Is visual basic full of errors? We have a VB program here at my work and I hear people say it doesn't always work right. I just figured it was user error. I'm actually in the middle of a VB book right now.. Would this language be worth my while to learn? Quote Link to comment Share on other sites More sharing options...
dbroada Posted May 14, 2010 Author Share Posted May 14, 2010 FORTRAN is the only language that I have had ANY formal instruction in so I prefer to use BASIC which looks similar. VBA is a sub set of Visual BASIC and is my language of choice as I find it a lot easier than LISP to do quickly (I am an occasional programmer). However, VBA is no longer supported by Microsoft and therefore being phased out by AutoDesk too. VBA isn't quite the same as VB. VB.Net will be available but I am struggling with that at the moment. I can't find enough tutorials on VB.Net for AutoCAD to get more than frustrated with my progress so far. 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.