Jump to content
JackStone

Names and properties of all Cell Styles in a Table Style

Recommended Posts

Good evening, everyone.

 

When manually creating table styles you can create custom cell styles and set, for each of them, a horizontal and a vertical margin.

 

I'm trying to change an existing table style via LISP. I need to check each cell style, extract the values of its horizontal and vertical margins, multiply those values by a factor and then set these new products as the horizontal and vertical margins of that cell style.

 

My problem is that I don't seem to find reference to cell styles anywhere. I can't find them using entget and I can't find them listed in vlax-dump-object.

 

Is there a way to get the names of all the cell styles defined in a table style? And then is there a way to change the properties of such cell styles (namely the horizontal and vertical cell margins)?

 

The most promising thing I've found so far is the GetCellStyles method (which is supposed to list by name the defined cell styles), but I can't seem to be able to use it correctly. No matter which arguments I supply to it I always get nil. Does anyone know how to use the GetCellStyles method?

 

I thank you all in advance.

 

PS.: there are a HorzCellMargin and a VertCellMargin methods (40 and 41 groups in the tablestyle entity list), but the values there apply only to the standard cell styles ("Data", "Header" and "Title").

Share this post


Link to post
Share on other sites

Hi Jackstone

 

 

For your first question, I'd be curious to know why there isn't any example into Active-x Reference guide regarding vla-getCellStyles beside "object.GetCellStyles cellStylesArray", and when I try using it with dictobj bound to the table style dictionnary...

 

 

(vlax-for eachentry dictObj
(princ (vla-get-name(vla-GetCellStyles eachentry))))

I get the following message..; error: too few actual parameters

After looking at the Signature in the reference "object.GetCellStyles cellStylesArray " it seems that it requires an array so I tried this...

 

Command: (vla-GetCellStyles dictObj)

; error: ActiveX Server returned the error: unknown name: GetCellStyles

So vlide see vla-GetCellStyles as a valid function, but yet the error it returns make me think otherwise. I'm rather new to active-X so maybe just like you I'm just trying to use it the wrong way, or maybe I just have a bad interpretation of the error message.

 

 

In the other hand, for your other question, you can easily get the margins using vla-get-HorzCellMargin and vla-put-VertCellMargin, store them, multiply them, and then change them with vla-put-HorzCellMargin and vla-put-VertCellMargin. You also can use some values directly. Please take a look at the following example to change the values...

(defun c:Example_CellMargin_by_Jef()
  (setq acadObj (vlax-get-acad-object))
  (setq doc (vla-get-ActiveDocument acadObj))
  (setq dictionaries (vla-get-Dictionaries doc))
  (setq dictObj (vla-Item dictionaries "acad_tablestyle"))
  (setq keyName "Copy of Standard");name of table style to be changed
  (setq tempObj (vla-GetObject dictObj keyName))
  (vla-put-HorzCellMargin tempObj 0.22)
  (vla-put-VertCellMargin tempObj 0.25)
  )

The only thing I couldn't figure out on the fly, is if there is any way to target any specific cell styles, because with this example it modify the margins of all the cell styles of the said Table style... maybe it could still suit your needs...

 

 

I have to leave for now, i'll try to sleep on that, perhaps ill vla-get-an-illumination in my sleep. Hoping I gave you some food for thoughts,

Cheers

Share this post


Link to post
Share on other sites

You should be able to get a individual row height if thats what you want this is column (vla-setcolumnwidth objtable 0 15) ; 0 is first column I thinks it Vla-setrowheight, trying to find example.

 

(setq objtabl (vlax-ename->vla-object (car (entsel)))) ; pick table
(vla-getrowheight objtable 12) ; this is the 12th row change to test.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×