Jump to content

VBA generate scr file


mien

Recommended Posts

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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...