Add a Data Row to the Top of the Table

Add a Data Row to the Top of the Table

kpennell
Collaborator Collaborator
1,894 Views
17 Replies
Message 1 of 18

Add a Data Row to the Top of the Table

kpennell
Collaborator
Collaborator

I tend to have a difficult time modifying dotted pair lists.  But I'm looking for a way to modify a table that automatically gets generated.  It has a Title Row, Header Row and of course several Data Rows.  I'd like to add a data row at the top, then in each of the cells write some text.  I'm assuming a good starting point, is to take all the 141 dotted pairs and insert an extra 141 dotted pair.

 

Original (141 . 5.0) (141 . 4.33333) (141 . 4.80952) (141 . 4.80952) (141 . 4.80952)

New (141 . 5.0) (141 . 4.33333) (141 . 4.80952) (141 . 4.80952) (141 . 4.80952) (141 . 4.80952)

 

Then to make sure the values are what I need them to be, but again, i'd have to insert them in the dotted pairs in the right order for them to be at the top data row.  All of this of course, using entmod.

0 Likes
Accepted solutions (2)
1,895 Views
17 Replies
Replies (17)
Message 2 of 18

pbejse
Mentor
Mentor



@kpennell wrote:

I tend to have a difficult time modifying dotted pair lists.  But I'm looking for a way to modify a table that automatically gets generated. 

 

.... All of this of course, using entmod.


Quick question: Why entmod?

The thought of using other than ActiveX to modify a table never cross my mind.

 

 

0 Likes
Message 3 of 18

kpennell
Collaborator
Collaborator

Because I don't know any better? ¯\_(ツ)_/¯

0 Likes
Message 4 of 18

pbejse
Mentor
Mentor

@kpennell wrote:

Because I don't know any better? ¯\_(ツ)_/¯


 

Fair enough, most of the time, the answer is "Im using Mac" 🙂

Post a drawing sample. I think its easy to come up with an vanilla solution for modifying a ACAD_table

 

<<<  Shop Before and After please >>>

 

 

0 Likes
Message 5 of 18

Sea-Haven
Mentor
Mentor

Have you looked at VLA-INSERTROW method.

 

 (vla-insertrows tb 1 1 1) look up help

(setq rownum (vla-get-rows obj2))
(vla-InsertRows obj2  rownum  (vla-GetRowHeight obj2 (- rownum 1)) 1)

 

 

0 Likes
Message 6 of 18

pbejse
Mentor
Mentor

@Sea-Haven wrote:

Have you looked at VLA-INSERTROW method.


 

Exactly. But I think this topic is more an exercise for list manipulation.

Let see what the OP have in mind.

 

0 Likes
Message 7 of 18

kpennell
Collaborator
Collaborator

I have seen examples of vla-InsertRows, but they tend to add rows to the end of the table.  As per all your comments, I do think vla is the way to go, and not 'entmod'.

0 Likes
Message 8 of 18

pbejse
Mentor
Mentor
Accepted solution

@kpennell wrote:

 I do think vla is the way to go, and not 'entmod'.


 Shame you're giving up on entmod. I really thought its more of an  exercise for list manipulation than anything. 

 


@kpennell wrote:

I have seen examples of vla-InsertRows, but they tend to add rows to the end of the table. 


Go for it then.

Not really you can assign the index as per @Sea-Haven  post

 

 

(setq tb (vlax-ename->vla-object (CAr (entsel))))
(setq rownum (vla-get-rows tb))
(vla-InsertRows tb  1  (vla-GetRowHeight tb (- rownum 1)) 1)

 

 

1 = The first Row

And in your case should be 2 . as the first Data row after Title (0) Header (1)

 

Try it.

HTH

 

 

0 Likes
Message 9 of 18

kpennell
Collaborator
Collaborator

I think, 'entmod' will still have it's place, when I want to modify the 'new' blank cells with strings that I want to have in there.

 

(vla-InsertRows tb 2 (vla-GetRowHeight tb (- rownum 1)) 1)

 

... worked great.  I need to get up to speed on vla.  I can't seem to grasp it at all.

0 Likes
Message 10 of 18

pbejse
Mentor
Mentor
Accepted solution

@kpennell wrote:

I think, 'entmod' will still have it's place, when I want to modify the 'new' blank cells with strings that I want to have in there.


I think you should go VL all the way @kpennell 

((lambda (n)
   (mapcar '(lambda (str)
	      (vla-settext tb 2 (setq n (1+ n)) str)
	      str
	    )
	   '("This" "is" "the" "data" "kpennell");<--- your string values
   )
 )
  -1
)

 

HTH 

0 Likes
Message 11 of 18

kpennell
Collaborator
Collaborator

vla.  where do I start reading?

0 Likes
Message 12 of 18

pbejse
Mentor
Mentor

@kpennell wrote:

vla.  where do I start reading?


Good for you kpennell, This a good place to start Visual LISP 

 

0 Likes
Message 13 of 18

Sea-Haven
Mentor
Mentor

Vlisp and tables is a bit complicated but plenty of examples for me at times trial and error and of course Google.

 

 

Message 14 of 18

pbejse
Mentor
Mentor

@pbejse wrote:

@kpennell wrote:

 I do think vla is the way to go, and not 'entmod'.


 Shame you're giving up on entmod. I really thought its more of an  exercise for list manipulation than anything. 



I went ahead and tried it for myself. it took a whole lot of codes compared to just using vla-InsertRows, breaking the entity data apart, modifying the associated list, adding new stuff and then putting it back together. I'm not going through that again.

 

sweat.png

But it was fun though. 

 

 

0 Likes
Message 15 of 18

kpennell
Collaborator
Collaborator

You have certainly taught a man how to fish.  At least with a pole, and not yet a net.

 

There are tons of reference material that articulate all the functions and the arguments required for each.  Is there an equivalent for VLisp functions/methods, like vla-insertrows?

 

I haven't looked at the text files that @Sea-Haven  posted yet.  I will be doing that shortly.

 

Thanks so much all, for the enlightening conversation.

0 Likes
Message 16 of 18

kpennell
Collaborator
Collaborator

I'm getting:

 

; error: Automation Error. Invalid input

 

for the Make Table.lsp file

0 Likes
Message 17 of 18

Sea-Haven
Mentor
Mentor

Sorry my fault I am trying to put values to columns that do not exist.

set the column number to 5 (setq numcolumns 5)

 

0 Likes
Message 18 of 18

kpennell
Collaborator
Collaborator

Very nice.  I can see this being extremely valuable.

0 Likes