This is a snippett of code I use in a routine to determine the drawing name and
insert it into the
drawing. Basically, if the drawing was created using a earlier version of Acad,
the drawing name is
formatted differently that with R14, which is what I use. Most of this is
concerned with parsing
the variable "dwgname" which comes in various flavors depending on the version
of Acad the drawing
was created in. When all is said and done, the variable "dwg2" in this snippett
holds the drawing
name without the path or the extension. This works for all versions up to
R14.01
(if
(< (getvar "acadver") "14")
(setq dwg (getvar "dwgname"))
(setq dwg (strcat (getvar "dwgprefix") (getvar "dwgname"))))
(setq dwgl (strlen dwg))
(if
(< (getvar "acadver") "14")
(setq dwg dwg)
(setq dwg (substr dwg 1 (- dwgl 4))))
(setq dwgl (strlen dwg))
(setq pos "t" ct -1)
(while pos
(setq ct (+ ct 1))
(setq name (strcase (substr dwg (- dwgl ct) 1)))
(if (or (= name "\\") (= name "")) (setq pos nil))
(setq dwg2 (substr dwg (- dwgl (- ct 1)))))
(setq dwg2 (strcase dwg2))
R. Wink
Thanks much! was just what I was looking for!
Here's another question along the same lines
Lets say I wanted to make a routine that would change the date and or
the total number of pages on all title blocks (even if just opening
them one at a time) so they all have the same date and quantity of
pages. Any ideas?
TIA!
(Brand Z) wrote:
Since you insist I ask, may I please have a copy of your VB routine to change
instances of the title
blocks across multiple drawings? And could you please explain how VB differs
from a script? I'm
just getting started in scripts and have no experience in VB.
R. Wink
It's not that I insist you ask. I don't like posting info nobody wants
to the NG, as it wastes bandwidth. I don't generally email people
without them asking. Some people are terribly irritated by unsolicited
emails. Think before you start being a wise-ass.
A script is simply a series of commands. They can generally be written
by copy/pasting out of Acad's textscreen, and removing the "Command:"s
and other such text.
Lisp and VBA are programming languages, which offer much more
flexibility and power. They provide a means of interracting with the
user. As to the difference between lisp and VBA.........they're
entirely different, though they have similar abilities.
IMO, VBA has the following two advantages:
1. Dialog boxes are much easier to make and control.
2. VBA is a subset of VB, and can be used in other apps, as well as ASP
(Active Server Pages on the internet/intranet).
IMO, AutoLisp's biggest advantage is that it is easier to learn,
particularly for someone with solid Acad skills. The lisp language was
originally created as a list processing language, so it does handle
lists of information MUCH easier than VBA does.
If you're just starting, dabble in both. My guess is that AutoLisp will
give you more impressive results much quicker.
I'll be emailing you the VBA macro.
Didn't mean to be a SA, just a little humor (apparently very little, I do that
on occation..or so my
wife tells me) Sorry.
I do a bit of programming in Lisp, did some in Basic (various flavors), Pascal
(various flavors),
Cobol and some C, all DOS based. Haven't done anything with the new "visual"
languages and don't
understand the dialog/mouse captures from the screen as opposed to painting the
screen and forcing
choices.
I'm just getting some scripts to run across multiple drawings and understand
some of the
requirements but don't (can't?) figure how to drag information from the DB in a
VB routine, in or
out of Acad.
R. Wink
So you know where I'm coming from, I was taught BASIC basics in 8th
grade (early 80's), and have learned lisp, VBA, etc. from books and the
web. I'm more of a hack than a programmer. I write quick & dirty
functional tools for myself, generally speaking.
Not sure what type of thing you're referring to. Re-post specifics and
I'm sure you could get a good answer here. Adesk's customization
group(s) also have some excellent regulars for programming.
I've done it with Rtext before, the problem with Rtext is that it only
works with 2000+ full and not LT. Had a problem with a customer not
being able to see the page numbers.
But thanks for the suggestion.
Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here.
All logos and trade names are the property of their respective owners.