Variables Not Being Set After a "SaveAs" and an "Open"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
In an effort to control the thousands of documents we work on for clients, I'm trying to introduce some limitations in drawings that we have issued to clients. The ideal workflow is that, when a drawing gets issued, it is set as read-only by the lead, or document control personnel (details to be ironed out later).
So I came up with some code to take the read-only drawing name and revision, do a saveas, and an open (I need to do an 'open' here, because a third party add-on still see the drawing as a 'read-only' drawing, even though the 'WriteStat' variable is set at 1).
(setvar "filedia" 0)
(setq FileBase (vl-filename-base (getvar "dwgname")))
(setq SetReadOnly (strcat (getvar "dwgprefix") (getvar "dwgname")))
(setq _Position (vl-string-search "_" FileBase))
(setq CurrentRevision (substr FileBase (+ _Position 3)))
(setq FileBaseR (substr FileBase 1 (+ _Position 2)))
(setq NewRevisionString (itoa (+ 1 (atoi CurrentRevision))))
(setq NewDwgName (strcat FileBaseR NewRevisionString))
(setq PathDwgName (strcat (getvar "dwgprefix") NewDwgName ".dwg"))
(if (findfile PathDwgName)
(prong
(Alert (strcat "\"" NewDwgName "\" already exists!"))
(exit)
);progn
)
(command "_.saveas" "" PathDwgName)
(command "_.open" PathDwgName)
After this though, none of my 'setq' functions are working. Though everyone one of my 'command' and 'setvar' functions are working.
If I comment out the (command "_.open" PathDwgName) using ";" the setq functions work perfectly.
I wouldn't think I'd need to use 'vl-bb-set' and 'vl-bb-ref' here because as I stated above:
(command "-layer" "set" "0" ""); works
(setq AssemblyListEnts (ssget "_X" '((0 . "ACAD_TABLE") (1 . "ASSEMBLIES")))); does not work
(command "zoom" "extents"); works
all the 'setq' work is done in the one drawing.