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:
Error after making field, referred to the Xref
« previous
next »
Print
Pages: [
1
] |
Go Down
Author
Topic: Error after making field, referred to the Xref (Read 2825 times)
0 Members and 1 Guest are viewing this topic.
frostmourn
Mosquito
Posts: 4
Error after making field, referred to the Xref
«
on:
September 30, 2015, 11:28:08 AM »
Hello all. I have got a problem during working with external references. Here the file AC-11 was used in the file AC-22 as attached Xref. Then doing the following code in it:
Code - Auto/Visual Lisp:
[Select]
(
defun
c:
123
(
/
LST adoc str_lst
)
(
vl-load-com
)
(
setq
adoc
(
vla-get-activedocument
(
vlax-get-acad-object
)
)
)
(
vlax-for
x
(
vla-get-blocks
adoc
)
(
if
(
equal
(
vla-get-isxref
x
)
:vlax-true
)
(
setq
LstXref
(
cons
x LstXref
)
)
)
)
(
foreach
x
(
get
-
block
-
contents
(
car
LstXref
)
)
(
if
(
wcmatch
(
vla-get-objectname
x
)
"*Text"
)
(
setq
LST
(
cons
x LST
)
)
)
)
(
setq
str_lst
(
mapcar
'
(
lambda
(
x
)
(
LM:ConstructFieldString x
"TextString"
""
)
)
LST
)
)
(
foreach
x
(
sstolist_vla
(
ssget
"_X"
'
(
(
8
.
"Specification"
)
(
0
.
"TEXT"
)
)
)
)
(
vla-put-textstring
x
(
car
str_lst
)
)
(
setq
str_lst
(
cdr
str_lst
)
)
x
)
(
vla-regen
adoc acActiveViewport
)
)
;; LM:ConstructFieldString
(
(
lambda
(
)
(
vl-load-com
)
(
if
(
null
acdoc
)
(
setq
acdoc
(
vla-get-activedocument
(
vlax-get-acad-object
)
)
)
)
(
eval
(
list
'
defun
'LM:ConstructFieldString '
(
ent prop format
/
ent
)
(
list
'
if
'ent
(
list
'
strcat
"%<
\\
AcObjProp Object(%<
\\
_ObjId "
(
if
(
and
(
vl-string-search
"64"
(
getenv
"PROCESSOR_ARCHITECTURE"
)
)
(
vlax-method-applicable-p
(
vla-get-utility
acdoc
)
'getobjectidstring
)
)
(
list
'vla
-
getobjectidstring
(
vla-get-utility
acdoc
)
'ent '
:vlax-false
)
'
(
itoa
(
vla-get-objectid
ent
)
)
)
">%)."
'prop '
(
if
(
not
(
eq
""
format
)
)
(
strcat
"
\\
f
\"
"
format
"
\"
>%"
)
">%"
)
)
)
)
)
)
)
(
defun
sstolist_vla
(
ss
/
i lst
)
(
setq
i
0
)
(
if
ss
(
repeat
(
sslength
ss
)
(
setq
lst
(
append
lst
(
list
(
vlax
-
ename
->
vla-object
(
ssname
ss i
)
)
)
)
i
(
1+
i
)
)
)
;end of repeat
)
lst
)
(
defun
get
-
block
-
contents
(
ent
/
def res _kpblc
-
conv
-
vla
-
to
-
list
)
; exam: (get-block-contents (car (entsel "\nВыберите блок")))
(
defun
_kpblc
-
conv
-
vla
-
to
-
list
(
value
/
res
)
(
cond
(
(
listp
value
)
(
mapcar
(
function
_kpblc
-
conv
-
vla
-
to
-
list
)
value
)
)
(
(
=
(
type
value
)
'
variant
)
(
_kpblc
-
conv
-
vla
-
to
-
list
(
vlax
-
variant-value
value
)
)
)
(
(
=
(
type
value
)
'
safearray
)
(
if
(
>=
(
vlax
-
safearray-get-u-bound
value
1
)
0
)
(
_kpblc
-
conv
-
vla
-
to
-
list
(
vlax
-
safearray
->
list
value
)
)
)
;_ end of if
)
(
(
and
(
=
(
type
value
)
'
vla-object
)
(
vlax-property-available-p
value 'count
)
)
(
vlax-for
sub value
(
setq
res
(
cons
sub res
)
)
)
;_ end of vlax-for
)
(
t value
)
)
;_ end of cond
)
;_ end of defun
(
cond
(
(
and
ent
(
=
(
type
ent
)
'ename
)
(
=
(
cdr
(
assoc
0
(
entget
ent
)
)
)
"INSERT"
)
)
;_ end of and
(
setq
res
(
get
-
block
-
contents
(
vlax
-
ename
->
vla-object
ent
)
)
)
)
(
(
and
ent
(
=
(
type
ent
)
'
vla-object
)
(
wcmatch
(
strcase
(
vla-get-objectname
ent
)
)
"*BLOCK*"
)
)
(
setq
def
(
vla-item
(
vla-get-blocks
(
vla-get-document
ent
)
)
(
vla-get-name
ent
)
)
)
(
setq
res
; (list
(
(
lambda
(
/
_lst
)
(
vlax-for
subent def
(
setq
_lst
(
cons
subent _lst
)
)
)
(
reverse
_lst
)
)
)
; (_kpblc-conv-vla-to-list (vla-getattributes ent))
; (_kpblc-conv-vla-to-list (vla-getconstantattributes ent))
; ) ;_ end of list
)
)
)
;_ end of cond
res
)
As a result we are obtaining a list of field codes, refering to the text entities on a specified layer in the Xref. And now if we paste codes to the texts in AC-22 trying to make working field, then after saving drawing will constantly get an error window - "recommended to do RECOVER procedure" (don't remember right wording).
I have tried to paste only textstrings; to process a simple block instead of Xref - all is good. Also tried using of Acad2016, saving in old versions, no matter. After re-opening file works correctly, audit shows 0 errors. Fields are the necessary condition here.
Can anybody give a solution or explanation at least? Will be happy even could to set off an error window.
System - Autocad 2010 x64 sp3 rus, SPDSGraphics 8.0, windows 7 pro x64 sp1. Thanks in advance.
Sorry for probably mistakes.
Logged
ronjonp
Needs a day job
Posts: 7531
Re: Error after making field, referred to the Xref
«
Reply #1 on:
September 30, 2015, 11:43:13 AM »
Not related to your code but ... first thing I see you should not be doing is putting special characters in your file names.
This is the dl'd file I see .. something weird going on.
Logged
Windows 11 x64 - AutoCAD /C3D 2023
Custom Build PC
frostmourn
Mosquito
Posts: 4
Re: Error after making field, referred to the Xref
«
Reply #2 on:
October 01, 2015, 04:24:14 AM »
Hmm, very strange... I see ordinary letters. It's something related with cyrillic encoding, I think.
Ok, here are files with only numbers using (by the way, it had no effect according to my problem...).
«
Last Edit: October 01, 2015, 04:32:12 AM by frostmourn
»
Logged
Print
Pages: [
1
] |
Go Up
« previous
next »
TheSwamp
»
Code Red
»
AutoLISP (Vanilla / Visual)
»
Topic:
Error after making field, referred to the Xref