How to use _Table in Autolisp

How to use _Table in Autolisp

Anonymous
Not applicable
1,599 Views
7 Replies
Message 1 of 8

How to use _Table in Autolisp

Anonymous
Not applicable

Hi everybody,

 

I'm new using Autolisp. With this weird time being inside all day long because of the coronavirus, I have time that I would like to use learning a little bit how to use AutoLisp.

 

I'm stating my learning with a routine that will put in a table some texts that the user would select by cliking in the drawing.

 

I managed to put all the texts that I want into one list. Now I want to use (command "_table") that I think would do a perfect job. But I can't find any information about the settings that I have to set. I figured out that the following parameters exist: "Number of Columns" "Number of Raws" "Insertion point" "Style" "Width" Height". But I can't understand how exactly I should write this parameter. I want to write something like (command "_table "P1 "P2"...). P meaning the parameter. Could you help me understand how the settings of _table work?

 

You can answer rather in english or french. Thank you very much!

0 Likes
Accepted solutions (1)
1,600 Views
7 Replies
Replies (7)
Message 2 of 8

hak_vz
Advisor
Advisor

I don't have a time to explain you all the details about creatingg tables . You can search this forum or use google to find many examples. You can use tags like "autolisp create table" or similar. There are also examples with vl-functions for dealing with table elements.

Here you can look at my last answer that was also related to creating tables, and try to figure out your solution.

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 3 of 8

ВeekeeCZ
Consultant
Consultant

If you want to create just an emptry table, use this:

(command "_.-table"
	 3				; # of culumns
	 2				; # of rows
	 "_Style" "Standard"
	 "_Height" 1
	 "_Width" 50
	 pause)

 

...but TABLEs are in general quite advanced stuff. So better start with something simpler.

Message 4 of 8

cadffm
Consultant
Consultant

Hi,

 

>"I have time that I would like to use learning a little bit how to use AutoLisp.

Thats good.

 

>"I'm stating my learning with a routine that will put in a table some texts that the user would select by cliking in the drawing."

That isn't a good idea.

A Table is one of the most complicated things you have in the drawing.

If you like to learn Lisp, start to learn how to use basic lispfunctions like * - + \

(/ 9 3)=3 (/ 10 3)=3 oh! (/ 10 3.0) 3.3333

and strcat strcase nth setq ..

 

Start here: https://www.afralisp.net/autolisp/tutorials/the-basics-part-1.php

Sebastian

Message 5 of 8

Anonymous
Not applicable

Hi @ВeekeeCZ , thanks for your answer. That's exactly what I wanted

 

Yes, looking online I've seen that tables are not the easiest thing to handle. But I think my routine is pretty simple to make, let me know if I'm wrong.

 

The purpose of my routine is to build a table to add to a document to make people (owners of lands) sign this document (AutoCAD Presentation) under their name. So, what I'm doing is to collect the name of each person who needs to sign the paper by clicking on the drawing, stock those names in a list (already done) and then I want to build a table that has 1 row and as many culumns than the number of owners who need to sign the document. So, in your anwer I need to replace the 3 (# of culumns) by a variable or an expression like (length liste) weher liste is the list of name I collected on the first step. But it's not working

The width total of the table has to be 187 (size of my page). So if I have two owners, each coloms needs to be 187/2. I've tried with  larg(/ 187 (eval (length liste))). But it's not working.

 

Later I'll have to see how I can pass from the model space to the paper space, but I want to take this step by step.

 

On this two problems I have the error error: argument type incorrect : numberp: nil (if I translate it from french). Do you have any hint about what should I write to fix this?

 

Thanks for the help!

0 Likes
Message 6 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

Just remove the EVAL.


(/ 187 (length liste))

BTW There is one catch about integers vs. reals which fortunately goes good for you in this your case.
If you divide two integers, the result would be also an integer - as your case. If any of the members would be a real, then the result would be a real.
Try (/ 3 2) vs (/ 3 2.)

 

@cadffm I knew I read it somewhere today from you... just didn't realize it was this thread 🙂

Message 7 of 8

Anonymous
Not applicable

@ВeekeeCZ Thank you so much! It looks like it works! I still have some stuff to fix but I'll try to do it alone!

Message 8 of 8

Sea-Haven
Mentor
Mentor

Making a table with just heading etc then you can use insertrows to add as many rows as you need as you read the list. The advantage is if you close the dwg you can pick an existing table and continue on adding more rows.

 

Also have a look at the attached.

0 Likes