Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Home
Help
Login
Register
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Help: Modify Lisp Scale block only
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Help: Modify Lisp Scale block only (Read 1830 times)
0 Members and 1 Guest are viewing this topic.
miquan
Guest
Help: Modify Lisp Scale block only
«
on:
December 18, 2013, 06:12:38 PM »
Dear all,
I tried to modified this lisp.
This is used to sclae block only with a scale factor.
I tried to store scale factor (by STR value in my lisp) from last command, and use it in the next one. But I failed.
Could you possibly help me?
Thanks,
Miquan
Code - Auto/Visual Lisp:
[Select]
(
defun
c:sb
(
/
tapblock sodt index soblocksua
entdt tt diemchen tyle DAIHT DAIMOI
TEMP str
)
(
init
)
(
princ
"
\n
Scale Block Only!"
)
(
setq
tapblock
(
ssget
'
(
(
0
.
"INSERT"
)
)
)
temp
(
initget
"R C"
)
(
SETQ
temp
(
GETVAR
"USERR3"
)
)
(
IF
(
=
temp
0
)
(
PROGN
(
SETQ
STR
"1"
)
(
SETVAR
"USERR3"
1
)
)
(
SETQ
STR
(
RTOS
temp
)
)
)
temp
(
getreal
"
\n
Scale Factor <"
STR
">:"
)
(
IF
(
=
temp
NIL
)
(
SETQ
temp
(
GETVAR
"USERR3"
)
)
(
SETVAR
"USERR3"
temp
)
)
tyle
(
cond
(
(
=
temp
"R"
)
(
setq
daiht
(
getdist
"
\n
Current Length: "
)
daimoi
(
getdist
"
\n
New Length: "
)
tyle
(
/
daimoi daiht
)
)
)
(
(
=
temp
"C"
)
(
setq
tyle
(
getreal
"
\n
New Scale Factor: "
)
)
)
(
t temp
)
)
sodt
(
sslength
tapblock
)
index
0
soblocksua
0
)
(
repeat
sodt
(
setq
entdt
(
ssname
tapblock index
)
index
(
1+
index
)
tt
(
entget
entdt
)
diemchen
(
trans
(
cdr
(
assoc
'
10
tt
)
)
0
1
)
soblocksua
(
1+
soblocksua
)
)
(
luuos
)
(
setvar
"OSMODE"
0
)
(
command
".scale"
entdt
""
diemchen tyle
)
(
traos
)
)
(
princ
(
strcat
"
\n
Number of Modified Blocks: "
(
itoa
soblocksua
)
)
)
(
sssetfirst
nil
tapblock
)
(
done
)
)
Logged
CAB
Global Moderator
Seagull
Posts: 10401
Re: Help: Modify Lisp Scale block only
«
Reply #1 on:
December 18, 2013, 08:58:27 PM »
Untested but may get you closer to your goal.
Code - Auto/Visual Lisp:
[Select]
(
defun
c:sb
(
/
tapblock sodt i ename tt diemchen daiht daimoi sb_scale
)
;(init)
(
princ
"
\n
Scale Block Only!"
)
(
setq
tapblock
(
ssget
'
(
(
0
.
"INSERT"
)
)
)
)
(
if
(
zerop
(
setq
sb_scale
(
getvar
"USERR3"
)
)
)
(
progn
(
setq
sb_scale
1
.
)
(
setvar
"USERR3"
1
.
)
)
)
(
initget
"R C"
)
(
setq
ans
(
getreal
(
strcat
"
\n
Scale Factor <"
(
rtos
sb_scale
2
2
)
">:"
)
)
)
(
cond
(
(
=
ans
"R"
)
(
setq
daiht
(
getdist
"
\n
Current Length: "
)
daimoi
(
getdist
"
\n
New Length: "
)
sb_scale
(
/
daimoi daiht
)
)
)
(
(
=
ans
"C"
)
(
setq
sb_scale
(
getreal
"
\n
New Scale Factor: "
)
)
)
(
(
=
(
type
ans
)
'real
)
(
setq
sb_scale ans
)
)
)
(
setvar
"USERR3"
sb_scale
)
(
setq
i
-
1
)
(
while
(
setq
ename
(
ssname
tapblock
(
setq
i
(
1+
i
)
)
)
)
(
setq
tt
(
entget
ename
)
diemchen
(
trans
(
cdr
(
assoc
'
10
tt
)
)
0
1
)
)
;(luuos)
(
setvar
"OSMODE"
0
)
(
command
".scale"
ename
""
diemchen sb_scale
)
;(traos)
)
(
princ
(
strcat
"
\n
Number of Modified Blocks: "
(
itoa
(
sslength
tapblock
)
)
)
)
(
sssetfirst
nil
tapblock
)
;(done)
)
«
Last Edit: December 19, 2013, 09:00:58 AM by CAB
»
Logged
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.
miquan
Guest
Re: Help: Modify Lisp Scale block only
«
Reply #2 on:
December 19, 2013, 12:51:24 AM »
Dear CAB,
Thanks for your reply, I tried but it's failed.
The error is "too many arguments"
I re-post here with my lisp and some sub function.
Please look at and give me some advices.
Thanks,
Miquan
Code - Auto/Visual Lisp:
[Select]
(
defun
c:sb
(
/
tapblock tt diemchen daiht daimoi ans sb_scale i
)
(
init
)
(
princ
"
\n
Scale Block Only!"
)
(
setq
tapblock
(
ssget
'
(
(
0
.
"INSERT"
)
)
)
)
(
if
(
zerop
(
setq
sb_scale
(
getvar
"USERR3"
)
)
)
(
progn
(
setq
sb_scale
1
)
(
setvar
"USERR3"
1
)
)
)
(
initget
"R C"
)
(
setq
ans
(
getreal
"
\n
Scale Factor <"
(
rtos
sb_scale
2
)
">:"
)
)
(
cond
(
(
null
ans
)
(
setq
ans sb_scale
)
)
(
(
=
ans
"R"
)
(
setq
daiht
(
getdist
"
\n
Current Length: "
)
daimoi
(
getdist
"
\n
New Length: "
)
sb_scale
(
/
daimoi daiht
)
)
)
(
(
=
ans
"C"
)
(
setq
sb_scale
(
getreal
"
\n
New Scale Factor: "
)
)
)
)
(
setvar
"USERR3"
sb_scale
)
(
setq
i
-
1
)
(
while
(
setq
ename
(
ssname
ss
(
setq
i
(
1+
i
)
)
)
)
(
setq
tt
(
entget
ename
)
diemchen
(
trans
(
cdr
(
assoc
'
10
tt
)
)
0
1
)
)
(
luuos
)
(
setvar
"OSMODE"
0
)
(
command
".scale"
ename
""
diemchen sb_scale
)
(
traos
)
)
(
princ
(
strcat
"
\n
Number of Modified Blocks: "
(
itoa
(
sslength
tapblock
)
)
)
)
(
sssetfirst
nil
tapblock
)
(
done
)
)
(
defun
miquan_newerror
(
msg
)
(
if
(
and
(
/=
msg
"Function cancelled"
)
(
/=
msg
"quit / exit abort"
)
)
(
princ
(
strcat
"
\n
"
msg
)
)
)
(
done
)
)
;;----------
(
defun
init
(
)
(
setq
miquan_CMD
(
getvar
"CMDECHO"
)
miquan_OLDERROR
*error*
*error*
miquan_newerror
)
(
setvar
"CMDECHO"
0
)
(
command
".undo"
"BE"
)
)
;;----------
(
defun
done
(
)
(
command
".redraw"
)
(
command
".undo"
"E"
)
(
if
miquan_CMD
(
setvar
"CMDECHO"
miquan_CMD
)
)
(
if
miquan_OLDERROR
(
setq
*error*
miquan_OLDERROR
)
)
(
princ
)
)
(
defun
luuos
(
)
(
setq
miquan_OSMODE
(
getvar
"OSMODE"
)
miquan_AUTOSNAP
(
getvar
"AUTOSNAP"
)
)
)
(
defun
traos
(
)
(
if
miquan_OSMODE
(
setvar
"OSMODE"
miquan_OSMODE
)
)
(
if
miquan_AUTOSNAP
(
setvar
"AUTOSNAP"
miquan_AUTOSNAP
)
)
)
Logged
CAB
Global Moderator
Seagull
Posts: 10401
Re: Help: Modify Lisp Scale block only
«
Reply #3 on:
December 19, 2013, 09:01:28 AM »
I updated the code in my post, try again.
Logged
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.
miquan
Guest
Re: Help: Modify Lisp Scale block only
«
Reply #4 on:
December 20, 2013, 10:41:31 AM »
Dear CAB,
It works perfectly, Thanks so much.
Miquan
Logged
CAB
Global Moderator
Seagull
Posts: 10401
Re: Help: Modify Lisp Scale block only
«
Reply #5 on:
December 20, 2013, 11:56:03 AM »
Glad to help.
Logged
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Help: Modify Lisp Scale block only