vlax-for limitation?

vlax-for limitation?

john.uhden
Mentor Mentor
778 Views
7 Replies
Message 1 of 8

vlax-for limitation?

john.uhden
Mentor
Mentor

I am trying to change the PlotStyleName of most of the 200 layers in one drawing.

Using vlax-for on the document's layer collection, it errors out on processing the 65th item...

  (vlax-put Layer 'PlotStyleName name)

; error: AutoCAD.Application: Key not found

The same holds true for vlax-map-collection.

Is there some limitation?  Should I change the collection to a list?  Would an occasional (gc) help?

John F. Uhden

0 Likes
Accepted solutions (3)
779 Views
7 Replies
Replies (7)
Message 2 of 8

paullimapa
Mentor
Mentor

if they both fail on the 65 item perhaps isolate just that layer and see if your code succeeds for that layer:

(vlax-put Layer 'PlotStyleName name)

Also go ahead and try the list alternative and see if it also fails on the 65th item


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 8

clindner
Advocate
Advocate
Accepted solution

I've seen vlax-put statements prefixed with a:

 

(vl-catch-all-apply

 

or used like this:

 

(api-error 'vlax-put-property

 

I believe this was to have the code continue even if an error is encountered (instead of just dumping out completely). 

 

It's a little over my head, but just throwing it out there fwiw.

 

Ok, TBH, it's more than a little over my head. 🙄


Please use the Accept as Solution or Kudo buttons when appropriate

Chris Lindner
CAD Technology Consultant @ onebuttoncad.com
AUGI Board of Directors

0 Likes
Message 4 of 8

Kent1Cooper
Consultant
Consultant

Is that Layer locked?

Kent Cooper, AIA
0 Likes
Message 5 of 8

john.uhden
Mentor
Mentor
Accepted solution

Oops.  I tried processing a list of the collection. It still errored out on the 83rd or 84th layer of the list.  Of those, 65 layers were changed successfully.  I dumped the "bad" layer and it appeared just fine..  Also, I had done an AUDIT first.

Since I hadn't sent this, I added a catch-all to the code to find out what layer was faulty and why...

"C-TOPO-CTCH-BNDY"  AutoCAD.Application: Key not found

And, yes, it continued processing all the other layers.  YAY!!

 

Now all I have to do is figure out how to handle viewports.  With the test drawing I was given, changing the global layer PlotStyleName changed the one viewport as well (?)

John F. Uhden

0 Likes
Message 6 of 8

john.uhden
Mentor
Mentor

@Kent1Cooper asked "Is that Layer locked?"

 

Nope.  I'll just have to alert the users that the layer(s) is/are bad and maybe to change the objects on the layer to a new one and delete the bad(s).  They can rename the new layer afterward.

John F. Uhden

0 Likes
Message 7 of 8

paullimapa
Mentor
Mentor
Accepted solution

Unless the collection is in error only layer objects should be changed and not vport objects. Also may be a good idea to generate a text file report to notify which layers that the code failed on so those can be examined afterwards 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 8

john.uhden
Mentor
Mentor

Kent,

Might you know where the viewport layer data is stored?

John F. Uhden

0 Likes