Ive just put together a little scaling LISP which allows the user to select objects (in my case its a title block for a 2D DRG) and scale them accordingly.
So my application is...
For 2D working DRGs - we have a title block inserted at whatever scale the DRG was originally created at - the user will wish to re-scale this title block... but the DIMSCALE, LTSCALE and text will need to also be scaled accordingly. We also have a field (ATTRIBUTE) within the title block which needs to note what scale the DRG is at.
So... i have created this routine - which does work... but i feel it requires a little too much input. Heres what is required by the user as they run this routine...
1. Run command. SSC
2. Select objects to scale. Title block and material list
3. Enter current scale. 50
4. Enter desired scale. 25
5. Enter scale as it currently appears in title block. 1:50
6. Enter scale as it will appear in title block. 1:25
As you can see - there is a bit of semi-repetition required by the user (though it is much simpler than modifying all the scale values manually).
I basically would like to eliminate steps 5 and 6 - have those inputs be read from steps 3 and 4 if possible.
It would also be fantastic if the data enter by the user in step 3 could be read automatically (maybe read it from the original DIMSCALE value - though this could be risky if the initial DIMSCALE was not set correctly).
(DEFUN C:ssc ()(setq ocmd (getvar "CMDECHO"))(prompt "\nSelect Title Block, Mark and Material List to be re-scaled... ")(setq sscpt1 '(0 0 0))(setq sscsset1 (ssget))(SETQ ssccs (getreal "\nEnter Current Scale : "))(SETQ sscds (getreal "\nEnter Desired Scale : "))(COMMAND "scale" sscsset1 "" sscpt1 (/ sscds ssccs))(COMMAND "dimscale" sscds)(COMMAND "ltscale" (* sscds 10))(COMMAND "-style" "PDC_Prosteel" "isocp.shx" (* sscds 3.5) "1" "0" "NO" "NO")(SETQ ssctso (getstring "\nEnter Current Scale as it appears in title block (1:5, 1:10, 1:50, etc): "))(SETQ ssctsn (getstring "\nEnter Desired Scale as it will appear in title block: "))(COMMAND "-attedit" "n" "n" "pdctitle" "pdcscale" "" ssctso ssctsn)(COMMAND "graphscr")(setvar "CMDECHO" ocmd)(princ))
You can avoid prompting the user for base scale by getting this from the title block entity - since you know the relation between drawing scale and block's insertion scale you can calculate the required value. Also may be safe to filter out entities other than blocks at selection:
So i ended up getting it to work quite well... though i havent quite been able to get the routine to read the current scale - little trickier.
I managed to tweak the code you gave me to read the initial inputs and compile the string (had to replace ITOA with RTOS - is that correct?).
One of the problems with reading the scale from the existing block is that the title block is not made up of just 1 block - it is a few different blocks, some lines, text, etc. So i will try to get the routine to read the scale from one of the blocks (select > blockname?).
So, with your help Mircea - i have managed to eliminate the need for steps 5 and 6... hopefully ill be able to get rid of step 3 soon too.
Can I ask a dumb question why are you not using layouts with your title block there ? draw at 1:1 plot at whatever scale you want. Its a better way to go than plotting from modelspace.
Good question mate - the software package were using with AutoCAD was setup by another drafting office, so we are pretty much following their procedure. Its for steel detailing, a model is created in one .DWG, then the 2D DRGs are created (exported from the model) in a lot of other .DWGs. The title block is all inserted as part of the export procedure... but the scale is always set as a default (1:10). The other office scale by manually editting each setting (as listed in first post) - i figured creating a routine to modify all settings at once would be good. And thanks to the help of Mircea... thats what i have.
Here is the final code - all working good. Required steps are as follows:
1. Run command. SSC
2. Select objects to scale. Title block and material list
4. Enter desired scale. 25
im afraid ive run into a few issues with this routine and will have to tweak it further. just wondering if anyone can please help me sort these issues out.
The problem i am having is that the scaling routine will only work when the DRGs units are set to zero decimal places. The process where the routine needs to find and replace a text string in a block relies on an exact match and the output must be to zero (or one decimal place in the case of half scales).
the routine will run perfectly when the DRGs units are set to zero decimal places AND the scale is a whole/round number.
- IF the DRGs units are set to anything but zero decimal places... the routine will only partially work, the rescaling will be completed but the title block will not be updated because of the mis-match between the value in the title block having zero decimal places and the entered value been read as having the same ammount of decimal places as the DRG.
- IF the DRG units are set to ZERO decimal places and a half scale is used (eg: 7.5)... the routine will only partially work, the rescaling will be completed but the title block will be updated incorrectly. The value in the scale field in the title block will be rounded to the neared round number.