Jump to content
SteveK

Some Simple Autolisp Questions.

Recommended Posts

CAB

FYI and a minor point.

(vl-load-com) is not needed for vl- functions but is required to be execuited once before any vla- vlax- or vlr- functions are used.

Share this post


Link to post
Share on other sites
Lee Mac
FYI and a minor point.

(vl-load-com) is not needed for vl- functions but is required to be execuited once before any vla- vlax- or vlr- functions are used.

 

I did not realise that - thanks Alan :thumbsup:

Share this post


Link to post
Share on other sites
Lee Mac
You welcome!

There is also possible to list all the entries in a specified definitions table – see below how to list all text styles defined in current drawing (may use MEMBER statement later to search if a particular style is in list):

 

(setq TStyleEntry (cdr (assoc 2 (tblnext "STYLE" 1)))
     TStylesList '())
(while TStyleEntry
(setq TStylesList (append TStylesList (list TStyleEntry))
      TStyleEntry (cdr (assoc 2 (tblnext "STYLE"))))
)

Regards

 

Another way:

 

(defun get_tbl_styles (/ tdef lst)
 (reverse
   (while (setq tdef (tblnext "STYLE" (not tdef)))
     (setq lst (cons (cdr (assoc 2 tdef)) lst)))))

Share this post


Link to post
Share on other sites
MSasu

@Lee Mac:

Indeed, concise solution!

Share this post


Link to post
Share on other sites
Lee Mac
@Lee Mac:

Indeed, concise solution!

 

Even more Concise:

 

(ai_table "BLOCK" 3)

Share this post


Link to post
Share on other sites
SteveK

How does that work Lee? ai_table isn't a function is it?

Share this post


Link to post
Share on other sites
Lee Mac
How does that work Lee? ai_table isn't a function is it?

 

Yes, it is a function defined in the ai_utils.lsp in the ACAD Support folder :)

 

Try it at the command line :)

Share this post


Link to post
Share on other sites
SteveK

Thats handy. And the 3 is the sum of 1 & 2:

1 = Do not list Layer 0 and Linetype CONTINUOUS.

2 = Do not list anonymous blocks or anonymous groups.

 

How do you discover these things? :)

Share this post


Link to post
Share on other sites
Lee Mac

Mostly from others code, and just curiousity I suppose :)

 

The ACAD.dcl is a nice one to peruse also, some handy widgets in there. :)

Share this post


Link to post
Share on other sites
SteveK

New Question: Retrieving a List of Selected Layouts...

 

I don't really want to start a new thread for a question so small, except if no one notices this question...

Does anyone know, when you select multiple layout tabs (with Ctrl), is there a way of outputting a list of the layout names of only those selected layouts?

 

The aim is to then do specific searches on only those selected tabs.

 

Appreciate any help.

 

 

 

Aside: As per the previous post I did a search for ACAD.dcl and nothing turned up.

Share this post


Link to post
Share on other sites
Lee Mac

To answer the aside first:

 

The ACAD.dcl is in a hidden folder :P

 

Something like this path:

 

C:\Users\<username>\AppData\Roaming\Autodesk\AutoCAD XXXX\RXX.0\enu\Support\

Share this post


Link to post
Share on other sites
Lee Mac

As for your other question - tbh, I am stumped :huh:

Share this post


Link to post
Share on other sites
SteveK

Regarding the main question:

 

Lee I don't think you've ever not been able to help me, now I'm worried no answer exists!

 

Though I would have thought there would be an answer, as Publish provides the layouts based on those selected, so it must retrieve it somehow.

 

 

 

 

About the aside: Ah, there ACAD.dcl is, it was hidden. I haven't made any dialog boxes yet, but I'm sure that'll come in handy when I do.

Share this post


Link to post
Share on other sites
CAB

(setq layout (dos_multilist "Select Layouts" "Select layouts" (layoutlist)))

. :roll:

Share this post


Link to post
Share on other sites
SteveK

Thanks CAB!

 

Just so others know; if you also get an error: dos_multilist is a DOSLib function, so load DOSLib before using.

 

Bit different to what I expected but it outputs a list of layouts, so it does the job. :)

Share this post


Link to post
Share on other sites
SteveK

Yeah I haven't done any C++ so Daniels solution is over my head (not that CAB's isn't, but it's shorter :)).

I'm happy with CAB's, I'll just include a (load DOSLib) in my code.

 

Lee: yes, I am learning C++, but I only started learning about 2 days ago
lol, I'm sure if only you had a week you would understand his code. how are your efforts to knock over as many languages as you can in a year going?

Share this post


Link to post
Share on other sites
Lee Mac
Yeah I haven't done any C++ so Daniels solution is over my head (not that CAB's isn't, but it's shorter :)).

I'm happy with CAB's, I'll just include a (load DOSLib) in my code.

 

I think CAB also included another solution in the Swamp thread, that didn't include the DosLib - you may be interested in.

 

lol, I'm sure if only you had a week you would understand his code. how are your efforts to knock over as many languages as you can in a year going?

 

Well, C++ is going to be a lot tougher to crack than LISP, but I shall have to see how I get on :)

Share this post


Link to post
Share on other sites
SteveK

I cannot see this other method you speak of, or at least maybe I need to have an account there to see it? Only the dos_multilist one.

Share this post


Link to post
Share on other sites
Lee Mac
I cannot see this other method you speak of, or at least maybe I need to have an account there to see it? Only the dos_multilist one.

 

Reply #4, I think you will need an account to see the attachments :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...