Jump to content

Recommended Posts

Posted

When I run this lisp with a script using Autoscript, all the code to change layers, etc. works fine, but it does not always zoom to extents and save in the zoomed position... only sometimes. I could run the script twice on the same files and get different results. The thing is, it zooms to extents, then zooms out a little, then saves it.

 

Also, the files that aren't properly zoomed to extents are about 4x larger, and if I open the file manually after it failed, zoom to extents then close it, it's fine.

 

What's going on? Is it running too fast or something? The log seems to indicate that everything works OK.

 

 
(defun c:tapconvert ()
;       *Runs various upgrades to tap cards converted from DGNs
;       *Changes layer names to friendly names, sets layer colors, sets active layer to Dimensions1, locks the 0 layer,
;  inserts blocks from block library, replaces symbols for objects with blocks, removes duplicate items,
;   purges unused items, zooms to extents, saves and closes the drawing.
;
;
; *Changes layer names from Microstation Levels to friendly names*
(setq old_name "Level 1" new_name "Border")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 2" new_name "Roadway")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 3" new_name "Road_Name")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 4" new_name "Building")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 5" new_name "Street_Text")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 6" new_name "Walkway")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 7" new_name "Top_Text")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 8" new_name "Water_Main")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 10" new_name "Dimensions1")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 11" new_name "Misc_Text")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 12" new_name "Reducer")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 15" new_name "Meter_Pit")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 22" new_name "Curb_Valve")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 26" new_name "Service_Tap")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 30" new_name "Manhole")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 37" new_name "Catch_Basin")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 60" new_name "Dimensions2")
(command "-rename" "layer" old_name new_name)
(setq old_name "Level 63" new_name "Misc")
(command "-rename" "layer" old_name new_name)
;
(command "-overkill" "ALL" "" ""); Removes duplicate drawing elements for cleanup / file size reduction
(command "purge" "A" "*" "N"); Purges all unused layers, blocks, etc. from the drawing to reduce file size*
;
; *Recreates and colors all layers to account for purged/removed layers*
(command "-layer" "M" "Border" "C" "T" "255,255,255" "" "")
(command "-layer" "M" "Building" "C" "T" "184,121,0" "" "")
(command "-layer" "M" "Catch_Basin" "C" "T" "185,185,185" "" "")
(command "-layer" "M" "Curb_Valve" "C" "T" "255,0,0" "" "")
(command "-layer" "M" "Dimensions2" "C" "T" "185,185,185" "" "")
(command "-layer" "M" "Manhole" "C" "T" "185,185,185" "" "")
(command "-layer" "M" "Meter_Pit" "C" "T" "184,121,0" "" "")
(command "-layer" "M" "Misc" "C" "T" "185,185,185" "" "")
(command "-layer" "M" "Misc_Text" "C" "T" "0,255,255" "" "")
(command "-layer" "M" "Reducer" "C" "T" "255,0,0" "" "") 
(command "-layer" "M" "Road_Name" "C" "T" "165,135,115" "" "")
(command "-layer" "M" "Roadway" "C" "T" "165,135,115" "" "")
(command "-layer" "M" "Service_Tap" "C" "T" "184,121,0" "" "")
(command "-layer" "M" "Street_Text" "C" "T" "184,121,0" "" "")
(command "-layer" "M" "Top_Text" "C" "T" "184,121,0" "" "")
(command "-layer" "M" "Walkway" "C" "T" "165,135,115" "" "")
(command "-layer" "M" "Water_Main" "C" "T" "0,135,255" "" "")
(command "-layer" "M" "Dimensions1" "C" "T" "185,185,185" "" ""); Recreates and colors Dimensions1 last to make it the active layer for editing
(command "-layer" "LO" "0" ""); *Locks the zero layer*  
;
;
; *Sets dimension style settings: all dimension scaling to 28x default, 1 decimal point, rounds to 1/2 foot, adds foot indicator*
(setvar "DIMSCALE" 28)
(setvar "DIMDEC" 1)
(setvar "DIMRND" 0.5)
(setvar "DIMPOST" "'")
;
(command "zoom" "e"); Zooms to extents
;(command "qsave") ; Saves drawing but Autoscript does this automatically
;(command "close") ; Closes drawing but Autoscript does this automatically
(princ "Processes Complete!")
)

Posted

Once I had an issue with Zoom - extents and I overcome with it in a strange way... Maybe this won't help you, but still who knows... This is what I did :

 

At the end of code after witch I had an issue with wrong Zoom -extents, I figured out that the problem was in my case with viewports that were in my DWG in 2 Layouts (Layout1 and Layout2)... It looked that larger viewport from one of the Layouts prevented me to Zoom to extents in Model space (tilemode 1)... So I decided that at the end of my code I do switching into all Layouts and only after that switch to (tilemode 1) and do zoom - extents... After this procedure, ACAD allowed me to correctly zoom... I don't know if this is the same problem as it was with me and my code but better something to change and watch the result than doing nothing and let it to be beaten by the machine - ACAD...

 

So, maybe, try :

 

(foreach lay (layoutlist)
 (setvar 'ctab lay)
)
(setvar 'tilemode 1)
(command "_.zoom" "e")

 

I hope you'll solve your problem in your way, as I don't see obvious lacks of your code...

 

M.R.

Posted

Thing is, I'm not using any layouts because these drawings are all simple extent prints, 8.5x11.

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