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:
Routine runs straight through but not complete.
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Routine runs straight through but not complete. (Read 935 times)
0 Members and 1 Guest are viewing this topic.
jlogan02
Bull Frog
Posts: 327
Routine runs straight through but not complete.
«
on:
April 20, 2023, 11:42:02 AM »
If I separate ----Test TBs----- from the ---dcl--- & ----Scale TBs------- all works fine in two separate routines. Combining them doesn't seem to work. Debugging isn't showing me anything at all. The routine goes through (for the most part) the entire routine.
I've experienced this before with combining routines and the same thing happened, so I'm assuming I'm missing a piece of the puzzle.
Code - Auto/Visual Lisp:
[Select]
(
vl-load-com
)
(
defun
c:spacex
(
/
ss attvalue dimsc blk1 fld1 siz names dsty dstydata userclick x obj obj1 obj2
olay ss ss1 ss2 tag1 tag2 att
)
(
defun
*error*
(
msg
)
(
if
osm
(
setvar
'osmode osm
)
)
(
if
(
not
(
member
msg '
(
"Function cancelled"
"quit / exit abort"
)
)
)
(
princ
(
strcat
"
\n
Error: "
msg
)
)
)
(
princ
)
)
(
setq
osm
(
getvar
'osmode
)
)
(
setvar
'osmode
0
)
(
setvar
'cmdecho
0
)
(
defun
lm:getattributevalue
(
blk tag
/
val enx
)
(
while
(
and
(
null
val
)
(
=
"ATTRIB"
(
cdr
(
assoc
0
(
setq
enx
(
entget
(
setq
blk
(
entnext
blk
)
)
)
)
)
)
)
)
(
if
(
=
(
strcase
tag
)
(
strcase
(
cdr
(
assoc
2
enx
)
)
)
)
(
setq
val
(
cdr
(
assoc
1
enx
)
)
)
)
)
)
;;------------------test and insert TBs---------------------------
(
setq
ss
(
ssget
"x"
'
(
(
0
.
"INSERT"
)
(
2
.
"ATTSubCode"
)
(
66
.
1
)
)
)
)
(
setq
attvalue
(
LM:GetAttributeValue
(
ssname
ss
0
)
"HIDDEN_SUBJCODE"
)
)
(
setq
dimsc
(
getvar
'dimscale
)
)
(
cond
(
(
wcmatch
(
strcase
attvalue
)
"03,05,84,60,62,64,80,66,67,68,72,70,71,73,74,86,88,89,82,83,90,92,93,94,96,98,41,42,43,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59"
)
(
command
-
s
"layout"
"t"
"TBLK_BORD_STR_STD"
"ANSI-D 22x34"
)
(
command
"Clayout"
"ANSI-D 22x34"
)
(
command
"_.-insert"
"STA_STR_STANDARDS"
"0,0"
dimsc dimsc
"0"
)
(
command
"-layer"
"filter"
"s"
"All"
""
)
(
command
"zoom"
"all"
)
)
(
(
wcmatch
(
strcase
attvalue
)
"05,01,10,14,16,40,12,29,20,22,30,34,32,35,41,42,56,44,46,48,49,50,52,67"
)
(
command
"Clayout"
"Model"
)
(
command
"_.-insert"
"BLANK"
"0,0"
dimsc dimsc
"0"
)
(
command
"explode"
"last"
)
;;(command "._layer" "unlock" "TTBK_BORD_LINES" "")
;;(command "._layer" "Make" "LINE1" "C" "YELLOW" "LINE1" "")
(
command
"Zoom"
"Extents"
)
)
)
;;-----------------dcl------------------
(
setq
SIZ
"0"
)
(
setq
NAMES '
(
"NONE"
"1/4
\"
= 1'-0
\"
"
"1/2
\"
= 1'-0
\"
"
"1
\"
= 1'-0
\"
"
"1-1/2
\"
= 1'-0
\"
"
"3
\"
= 1'-0
\"
"
"6
\"
= 1'-0
\"
"
)
)
(
setq
dcl_id
(
load_dialog
"STA_Scale_TB.dcl"
)
)
;load dialog
(
if
(
not
(
new_dialog
"STA_Scale_TB"
dcl_id
)
)
;test for dialog
(
exit
)
;exit if no dialog
)
;if
(
start_list
"scales"
)
;start the list box
(
mapcar
'
add_list
NAMES
)
;fill the list box
(
end_list
)
;end list
(
action_tile
"cancel"
;if cancel button pressed
"(done_dialog) (setq userclick nil)"
;close dialog, set flag
)
;action_tile
(
action_tile
"accept"
;if O.K. pressed
(
strcat
;string 'em together
"(progn
(setq SIZ (get_tile
\"
scales
\"
)))"
;get list selection
"(done_dialog)(setq userclick T))"
;close dialog, set flag
)
;strcat
)
;action tile
(
start_dialog
)
;start dialog
(
unload_dialog
dcl_id
)
;unload
(
if
userclick
;check O.K. was selected
(
progn
(
cond
(
(
=
SIZ
"0"
)
(
setvar
"dimscale"
1
)
)
;;FULL
(
(
=
SIZ
"1"
)
(
setvar
"dimscale"
48
)
)
;;1/4"
(
(
=
SIZ
"2"
)
(
setvar
"dimscale"
24
)
)
;;1/2"
(
(
=
SIZ
"3"
)
(
setvar
"dimscale"
12
)
)
;;1"
(
(
=
SIZ
"4"
)
(
setvar
"dimscale"
8
)
)
;;1 1/2"
(
(
=
SIZ
"5"
)
(
setvar
"dimscale"
4
)
)
;;3"
(
(
=
SIZ
"6"
)
(
setvar
"dimscale"
2
)
)
;;6"
)
;cond
(
setq
tag1
"DRAWINGSCALE"
)
(
setq
ss
(
ssget
"x"
'
(
(
2
.
"TBLK_ATT_STA"
)
(
66
.
1
)
)
)
)
(
repeat
(
setq
x
(
sslength
ss
)
)
(
setq
obj
(
vlax
-
ename
->
vla-object
(
ssname
SS
(
setq
x
(
-
x
1
)
)
)
)
)
(
if
(
=
(
vla-get-hasattributes
obj
)
:vlax-true
)
(
foreach
att
(
vlax-invoke
obj 'getattributes
)
(
if
(
=
tag1
(
strcase
(
vla-get-tagstring
att
)
)
)
(
vla-put-textstring
att
(
nth
(
atoi
siz
)
names
)
)
)
)
)
)
(
setq
tag2
"DESIGNER"
)
(
if
(
setq
ss1
(
ssget
"_X"
'
(
(
0
.
"INSERT"
)
(
2
.
"TBLK_ATT_STA"
)
(
66
.
1
)
)
)
)
(
repeat
(
setq
idx
(
sslength
ss1
)
)
(
setq
idx
(
1-
idx
)
obj
(
vlax
-
ename
->
vla-object
(
ssname
ss1 idx
)
)
)
(
vl-some
'
(
lambda
(
att
)
(
if
(
and
(
=
tag2
(
strcase
(
vla-get-tagstring
att
)
)
)
(
vlax-write-enabled-p
att
)
)
(
not
(
vla-put-textstring
att
(
strcase
(
substr
(
getvar
'loginname
)
1
3
)
)
)
)
)
)
(
vlax-invoke
obj 'getattributes
)
)
)
)
;;--------------------Scale TBs------------------------
(
setq
dimsc
(
getvar
'dimscale
)
)
(
command
"-layer"
"unlock"
"TTBK_BORD_LINES"
""
)
(
setq
blk1
(
ssget
"x"
'
(
(
2
.
"TBLK_BORD_CTL,TBLK_BORD_MAX,TBLK_ATT_STA"
)
)
)
)
;;TBLK_BORD_CTL
(
command
"scale"
blk1
""
"0,0"
dimsc
)
(
setq
fld1
(
ssget
"x"
'
(
(
8
.
"TTBK_TBLK_VAULTNO"
)
)
)
)
;;Vault number field.
(
command
"scale"
fld1
""
"0,0"
dimsc
)
;;(command "-layer" "lock" "TTBK_BORD_LINES" "")
(
setvar
"fielddisplay"
0
)
(
if
(
=
(
tblsearch
"layer"
"TTBK_TBLK_REVINIT"
)
)
(
command
"-Layer"
"Make"
"TTBK_TBLK_REVINIT"
"c"
"green"
"TTBK_TBLK_REVINIT"
""
)
)
(
setq
Odyn
(
getvar
'dynmode
)
)
(
setvar
'dynmode
0
)
(
while
(
setq
dsty
(
tblnext
"dimstyle"
(
not
dsty
)
)
)
(
setq
dstydata
(
entget
(
tblobjname
"dimstyle"
(
cdr
(
assoc
2
dsty
)
)
)
)
)
(
if
(
assoc
40
dstydata
)
; [because not included in data if default 1.0]
(
entmod
(
subst
(
cons
40
dimsc
)
(
assoc
40
dstydata
)
dstydata
)
)
; then -- replace it
(
entmod
(
append
dstydata
(
list
(
cons
40
dimsc
)
)
)
)
; else -- add it
)
)
(
command
"layer"
"M"
"LINE1"
"C"
"YELLOW"
"LINE1"
""
)
(
command
"limits"
(
getvar
"extmin"
)
(
getvar
"extmax"
)
)
(
command
"zoom"
"e"
)
(
setvar
"CMDECHO"
0
)
(
setvar
"BLIPMODE"
0
)
(
command
".style"
"Standard"
"ipco.shx"
(
*
1.000
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"L080"
"ipco.shx"
(
*
0.0781
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"L100"
"ipco.shx"
(
*
0.0938
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"L120"
"ipco.shx"
(
*
0.1094
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"L140"
"ipco.shx"
(
*
0.1406
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"L175"
"ipco.shx"
(
*
0.1563
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"L200"
"ipco.shx"
(
*
0.1719
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"L240"
"ipco.shx"
(
*
0.2187
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"Ls080"
"ipco.shx"
(
*
0.0781
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"Ls100"
"ipco.shx"
(
*
0.0938
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"Ls120"
"ipco.shx"
(
*
0.1094
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"Ls140"
"ipco.shx"
(
*
0.1406
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"Ls175"
"ipco.shx"
(
*
0.1563
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"Ls200"
"ipco.shx"
(
*
0.1719
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
(
command
".style"
"Ls240"
"ipco.shx"
(
*
0.2187
dimsc
)
"0.85"
"0"
"n"
"n"
"n"
)
)
;progn
)
(
setvar
"cmdecho"
1
)
(
setvar
"dynmode"
Odyn
)
(
command
"_zoom"
"e"
)
(
alert
"Way to go!!! You scaled the border."
)
(
princ
)
)
The theory is...
We have a 3rd party drawing vault where a properties card is filled out with a subject code for each drawing type. This routine would look at the subject code in the TB attribute and insert the correct title block. If the subject code is a model space code the dcl fires and asks the user for a scale (I know...why don't you use paper space?!?!? If you feel the need to discuss that, please move on.) I get the dcl to pop up and the dimscale is properly set from that selection, the line1 layer is set current but nothin else in that section is working.
Logged
J. Logan
ACAD 2018
I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10
jlogan02
Bull Frog
Posts: 327
Re: Routine runs straight through but not complete.
«
Reply #1 on:
April 20, 2023, 11:57:36 AM »
forgot to attach the dcl. Sadly, I can't attach company drawings.
Logged
J. Logan
ACAD 2018
I am one with the Force and the Force is with me.
AutoCAD Map 2018 Windows 10
BIGAL
Swamp Rat
Posts: 1434
40 + years of using Autocad
Re: Routine runs straight through but not complete.
«
Reply #2 on:
April 22, 2023, 08:07:35 PM »
A couple of suggestions, use a dwg template with your layouts all setup with different sizes, I dont understand why your scaling your title block, we never did that, that is what Mview is for set a scale for the view of the model objects
Re your dcl you can use this in future it only requires like 2 lines of code to make a dcl and get an answer. Look at examples in start of code, you get a string as answer form pick or for multiple choices look at the value of "but" and compare to a list.
By using a dwt all your layers are set and all your styles exist. We would get a dwg from a external source and just paste into our template so everything was there.
«
Last Edit: April 22, 2023, 08:11:04 PM by BIGAL
»
Logged
A man who never made a mistake never made anything
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Routine runs straight through but not complete.