Jump to content

LISP for controlling table row heights


Recommended Posts

Posted

Anyone out there? PLEASE HELP

 

I've been researching endlessly for days trying to figure out how to control the dam row height for my excel linked table.

 

Every time the text in a cell wraps to the next line, it automatically increased the cell's height to adjust around the next line of text. Which is fine, but when I edit the text back to a single line, the cells height does not adjust with it.

 

If there is a magic lisp out there that will make my cell heights adjust back automatically, that would be a jackpot... but I at least need a simple lisp that will automatically set my row heights to the following:

 

(inches)

row1= 0.53803341

row2= 0.15907332

row3-41= 0.32812500

Posted (edited)

... but I at least need a simple lisp that will automatically set my row heights to the following:

 

(inches)

row1= 0.53803341

row2= 0.15907332

row3-41= 0.32812500

 

hi, welcome to CADTutor

 

you can use cvunits for converting units

(cvunits number "inches" "meter") or vice verse

 

(defun c:test ( / ss tab)
(prompt "\nPick ACAD TABLE.. ")
(if(setq ss
(ssget "_+.:E:S:L" '((0 . "ACAD_TABLE"))))
((lambda (row /)
  (repeat row
     (vla-SetRowHeight
      tab
     (setq row (1- row))
      (cond ((=[color="red"] [b]0[/b][/color] row)[color="red"]0.53803341[/color])
     ((= [color="red"][b]1[/b][/color] row) [color="red"]0.15907332[/color])
    [color="green"] ;((= n row) height ) <-- add any row & height[/color]
     ([color="red"]0.32812500[/color]) [color="green"];<-- height other than above 1 row & 2 row[/color]
     )
      ) 
    )
  )
 (vla-get-rows (setq tab (vlax-ename->vla-object (ssname ss 0))))
 )
 (alert "\nNo Table?!")
)
 (princ))

Edited by hanhphuc
no header, ie: 0=1st row 1=2nd row
Posted

Thanks for replying so soon hanhphuc. Unfortunately I wasn't able to get it to work. It could be me, I don't know much about lisp. I tried typing in APPLOAD and I tried dragging and dropping the .lsp file. I do see you do have the correct heights in there. I'm not sure what you mean about cvunits. Let me try to clarify the problem, and the solution I'm looking for.

 

1.) I start off with my table linked to my excel spreadsheet. (every things fine)

 

2.) I download the information from my spreadsheet into my table, and when some of the cell's text wrap to the second line, the row height is thrown out of wack.

 

3.) We can't alter our index borders (strict company standards). So if the original text loaded into the cells is too long, we have to shorten our titles just enough to fit a single line of text. But with my table, the rows will not adjust back to their original height after fixing the text back to single line.

 

4.) This is where I need a lisp that I can load in that will automatically fix my rows back their original heights. Otherwise I have to do it manually, which is a deal breaker for my fellow coworkers.

 

I have 41 rows total.

 

Original Row Heights

row1= 0.53803341

row2= 0.15907332

row3 thru row41= 0.32812500

 

(I hope these pictures attached correctly)

 

1- Correct Row Heights.jpg

 

2 - Original text loaded in.jpg

 

3 - Fixed Text but rows don't update.jpg

 

4 - Manually Fixed Row Heights.jpg

Posted

Sorry hanhphuc, i had to do some research to figure out how to run the lisp correctly. It runs through every row and fixes the row height just like i needed but it sets row 2 to the same height as row 1. I tried play around with it but i couldnt figure it out. Any ideas?

Posted
Sorry hanhphuc, i had to do some research to figure out how to run the lisp correctly. It runs through every row and fixes the row height just like i needed but it sets row 2 to the same height as row 1. I tried play around with it but i couldnt figure it out. Any ideas?

 

 

Table row is zero based, after looking in your image with/without header 0=1st row ,1=2nd row etc..

code will be updated soon

(cond ((= [color="red"][b]0[/b][/color] row) 0.53803341)
     ((= [color="red"][b]1[/b][/color] row) 0.15907332)
    	     (0.32812500); <-- height other than above 1 & 2
     )

 

manually:

Pick a cell in table then edit its Cell Height in Properties window,

if no changes maybe some limitation? (eg: text height greater than row height etc..)

 

p/s: my version does not have excel link feature

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...