View Full Version : Lisp fishing
Robert.Hall
2005-01-20, 09:49 PM
Anyone got a lisp for scaling drawings from millimeters to inches??
Frequently I use a scale factor of .03937007874 to go from millimeters
to inches. Would be nice if I had a lisp routine to take me back and
forth between english and metric (25.4).
scwegner
2005-01-20, 10:28 PM
Anyone got a lisp for scaling drawings from millimeters to inches??
Frequently I use a scale factor of .03937007874 to go from millimeters
to inches. Would be nice if I had a lisp routine to take me back and
forth between english and metric (25.4).
Off the top of my head without checking it:
;;;SWITCH
(defun c:switch ( )
(if
(= (getvar "lunits") 4)
(progn
(command "scale" "all" "" "0,0,0" "25.4")
(setvar "lunits" 2)
(princ "\nDrawing converted to metric")
);progn
(progn
(command "scale" "all" "" "0,0,0" "0.03937007")
(setvar "lunits" 4)
(princ "\nDrawing converted to imperial")
);progn
);if
(command "zoom" "e")
(princ)
)
It may not be the most elegant code but it'd work. Anyone else? Come on, Mike, I know you can come up with something better.
Robert.Hall
2005-01-21, 02:54 PM
Thats not quite it......all that does is change dimensions.
Im looking to scale the actual part so that it is either drawn in millimeters or inches.
I require selecting a part and having it automatically scale from millimeter to inches.
Also would like inches to millimeters. This will disallow anyone to "fat finger" the
scale factor.
scwegner
2005-01-21, 04:18 PM
Thats not quite it......all that does is change dimensions.
Im looking to scale the actual part so that it is either drawn in millimeters or inches.
I require selecting a part and having it automatically scale from millimeter to inches.
Also would like inches to millimeters. This will disallow anyone to "fat finger" the
scale factor.
No, it scales the whole drawing and then changes the units. So your one unit is converted to 25.4 units and from architectural to decimal or vise versa. It doesn't touch the dims at all. Actually, that's something I forgot to add in -a command to change the dimension suffix. Still, when I tried it on one of my own drawings, it seemed to work just fine.
Robert.Hall
2005-01-21, 05:01 PM
Oh, I see.....all I want to do is select a part to be scaled. This routine
seems to scale everything.
scwegner
2005-01-21, 05:27 PM
Oh, I see.....all I want to do is select a part to be scaled. This routine
seems to scale everything.
Gotcha, I misunderstood your question. So let me see if I get it now: are you inserting something then wanting to scale it to match the rest of the drawing? Or are you taking a part that you've drawn and just converting the units?
Robert.Hall
2005-01-21, 07:38 PM
Customer spec is given in millimeters........so I draw with 1200 units etc.
Need to work in inches so I constantly scale the parts to inches.
Also would be nice to be able to go the other way.
cwitt
2005-01-26, 12:06 AM
(defun C:SCI (/ sset)
(setvar "CMDECHO" 1)
(setq sset (ssget))
(if (= sset nil)(exit))
(command ".SCALE" sset "" pause "10/254")
(setvar "CMDECHO" 0)
(princ)
)
(defun C:SCM (/ sset)
(setvar "CMDECHO" 1)
(setq sset (ssget))
(if (= sset nil)(exit))
(command ".SCALE" sset "" pause "25.4")
(setvar "CMDECHO" 0)
(princ)
)
Sorry for the *edit* but code reads much better when the "Code (http://forums.solidvapor.net/misc.php?do=bbcode#code)" button is used.
For further details please refer to "Reading and Posting Messages (http://forums.solidvapor.net/faq.php?faq=vb_read_and_post)" on the FAQs Page (http://forums.solidvapor.net/faq.php?).
Mike (Forum Moderator)
Robert.Hall
2005-01-26, 06:21 PM
Anyone else care to take a shot at this??
scwegner
2005-01-26, 06:29 PM
Anyone else care to take a shot at this??
Sorry, I'm kind of busy to fiddle right now but I'll get back to you later. I really shouldn't be surfing the forums at all but....
Something I use quite a bit when dealing with our metric manufacturers is a little transparent command to convert from metric to imperial as I'm drawing. So when it prompts for a distance, I just hit the convert option then type in the metric distance and it enters the imperial equivolent. It may be annoying for you to be doing that every time if you are drawing in metric a lot, but since I go back and forth so much it's easier for me.
cwitt
2005-02-01, 07:11 PM
scwegner,
I did somthing just like that.. only on a more limited scale..
we have a I/M switch on the offset, chamfer and fillet commands..
I would LOVE to see how you got a switch to work for all distance related commands..
scwegner
2005-02-01, 07:20 PM
scwegner,
I did somthing just like that.. only on a more limited scale..
we have a I/M switch on the offset, chamfer and fillet commands..
I would LOVE to see how you got a switch to work for all distance related commands..
I didn't really. At least I don't think it's what you're talking about. Since I don't do it quite often enough to bother with all that, I just have a transparent command that takes whatever I enter in inches and returns it in metric. So when I'm prompted for an imperial distance and want to enter metric, I hit the button or type "mm" or use right-click to launch my tiny LISP. Nothing fancy at all. Maybe I should put a little effort into it though and figure out a real switch. I've been overloaded lately and just haven't gotten around to it.
I'd be curious to know what exactly you did though.
cwitt
2005-02-01, 07:37 PM
I'd be happy to show you the code (basically an overlay on the core commands).
email? (as there is alot of code).
Robert.Hall
2005-02-01, 10:29 PM
The lisp routine Cwitt created works great.........I just want to see if anyone can
combine this into 1 routine. Otherwise I have what I need.
cwitt
2005-02-01, 11:34 PM
a quick FYI.. I didn't "create" those 2 lisp commands.. (sci/scm) .. but I also don't remember who did.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.