mien Posted April 10, 2009 Share Posted April 10, 2009 i wrote this code to generate *.scr file. but it seem not so good and perform as it should be. can someone give me advice to make this code better. here i attach the code. thanks... VBA Code.txt Quote Link to comment Share on other sites More sharing options...
SEANT Posted April 10, 2009 Share Posted April 10, 2009 Unfortunately, I don’t think I can help much with constructing the script file. If you don’t mind my asking, though, is there a purpose to creating the script instead of just having the VBA routine perform the task? Quote Link to comment Share on other sites More sharing options...
mien Posted April 10, 2009 Author Share Posted April 10, 2009 seant, im very new in this VB. i tried to add coordinate with Z text with generate scr file. do you have any idea with VBA code to perform the task. here i attach the scr file that the code i wrote should be perform. thanks... test.zip Quote Link to comment Share on other sites More sharing options...
SEANT Posted April 10, 2009 Share Posted April 10, 2009 Now that I’ve given it some thought, I can imagine situations where generating a .SCR file would be appropriate. Again, it’s not something I’ve done so I can’t offer much assistance. If the .SCR does not have some additional purpose then that extra step may not be needed. Conceivably, you are referencing a database to produce the .SCR: That same Database could just as easily (and probably much more quickly) allow VBA to create the geometry directly. Quote Link to comment Share on other sites More sharing options...
mien Posted April 10, 2009 Author Share Posted April 10, 2009 seant, do you have any idea to do the task using VBA..import the ASCII file contain x,y,z coordinates. then, plot it to autocad..i try autocad VBA thisdrawing.modelspace.addpoint code but it not working. Quote Link to comment Share on other sites More sharing options...
SEANT Posted April 10, 2009 Share Posted April 10, 2009 The ASCII would have to be parsed correctly, so knowledge of the files structure is critical. How was the ASCII created? If it was done by Excel or Access, there are numerous tutorial on the internet (many are here at CadTutor) showing how to connect Microsoft Office applications with AutoCAD via VBA. Quote Link to comment Share on other sites More sharing options...
mien Posted April 10, 2009 Author Share Posted April 10, 2009 it was done by NavEdit (hydrographic survey software). Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 14, 2009 Share Posted April 14, 2009 I think your over complicating it also why not just read the source file in and create the autocad objects as mentioned above. You only need to create the layers once at the start then just set to that layer and all the colours linetypes etc are done. I would write a function for each of the different layer entries then your code would be something like create new layers open file read line call WMH_PDEPTH(x,y,z) call WMH_BDEPTH(x,y,z) call WMH_SDEPTH(x,y,z) next line close job done zoom extents each call does something like create point Please paste some source data so we get a better idea of what your trying to read. Quote Link to comment Share on other sites More sharing options...
mien Posted April 14, 2009 Author Share Posted April 14, 2009 hi bigal, here i attach the data...thankss.. Hydro.zip Quote Link to comment Share on other sites More sharing options...
mien Posted April 14, 2009 Author Share Posted April 14, 2009 here i attach the userform i exported form VBA...i tried to make this code sendcommand to commandline same as scr do.. ACAD.zip Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 17, 2009 Share Posted April 17, 2009 here is a lisp file to read xyz points (setvar "menuecho" 0) (setvar "SNAPMODE" 0) (SETQ OLDSNAP (GETVAR "OSMODE")) (setvar "OSMODE" 0) (setq xyzfiles (getfiled "\nENTER CO-ORD File name " "" "" 4)) (setq fopen (open xyzfiles "R")) (command "zoom" "E") (SETQ XX 1) (while (setq new_line (read-line fopen)) (PRINC XX) (setq easting (substr new_line 1 ) (setq northing (substr new_line 10 9)) (setq height (substr new_line 20 5)) (setq ptxyz (list (atof easting)(atof northing) (atof height))) (command "point" ptxyz) (SETQ XX (+ XX 1)) ) ; end while (princ setsc ) (SETVAR "OSMODE" OLDSNAP) (princ) 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.