Jump to content

Names and properties of all Cell Styles in a Table Style


JackStone

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

Link to comment
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

Link to comment
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.

Link to comment
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
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...