TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: nivuahc on January 14, 2010, 04:08:18 PM

Title: [Help] Table Gridlines
Post by: nivuahc on January 14, 2010, 04:08:18 PM
I'm trying to re-create a table style like the one in the attached image. I'm using the one shown to try and figure out what I need to do to get that double-line at the bottom of the header row. So this is where I'm hitting a brick wall:

Code: [Select]
Command: (setq TblObj (vlax-ename->vla-object (car (entsel))))
Select object: #<VLA-OBJECT IAcadTable 0b7bf0e4>

Command: (vla-GetGridLinetype TblObj 0 1 acHorzBottom)
2128841888
I'm not sure what to make of 2128841888 but I'm hoping it's a way of identifying that the bottom gridline of the selected cell is a double-line. So I check the cell just below it:

Code: [Select]
Command: (vla-GetGridLinetype TblObj 1 1 acHorzBottom)
2128841896

Command: (vla-GetGridLinetype TblObj 1 1 acHorzTop)
2128841888

The bottom line throws out a completely different number and the top line throws out the same number as the bottom line in the cell above (like I would expect). Just for the record, I checked the Left and Right lines in this cell as well as a couple of others, all of them returning 2128841896 (which I'm guessing is a single line).

So I try the following:

Code: [Select]
Command: (vlax-put-property TblObj "SetGridLinetype" 2 1 acHorzBottom 2128841888)
; error: ActiveX Server returned an error: Type mismatch

Okay... what am I missing here?

EDIT: See below (i.e. I'm an idiot)
Title: Re: [Help] Table Gridlines
Post by: nivuahc on January 14, 2010, 04:10:08 PM
You know... I hate it when I ask a question, only to realize that it's a PEBKAC error after it's posted  :ugly:

EDIT: and still...

Code: [Select]
Command: (vla-SetGridLinetype TblObj 2 1 acHorzBottom 2128841888)
nil
Title: Re: [Help] Table Gridlines
Post by: Lee Mac on January 14, 2010, 04:21:14 PM
The integer is the enum for the Table line type, symbols like "acHorzBottom" will evaluate to such enum's also, but getting the symbol for the enum is something I would like to know also.

EDIT:  Perhaps use MP's Atoms.vlx to browse the symbols
Title: Re: [Help] Table Gridlines
Post by: T.Willey on January 14, 2010, 04:24:38 PM
A nil with ActiveX doesn't mean that it didn't work.  You might have to regen after the code to see if it worked, or you could try the Update method on the table.
Title: Re: [Help] Table Gridlines
Post by: Lee Mac on January 14, 2010, 04:27:21 PM
Tim,

How could one get the symbol associated with an enum?
Title: Re: [Help] Table Gridlines
Post by: nivuahc on January 14, 2010, 04:28:16 PM
A nil with ActiveX doesn't mean that it didn't work.  You might have to regen after the code to see if it worked, or you could try the Update method on the table.

Tried both, no dice  :-(
Title: Re: [Help] Table Gridlines
Post by: T.Willey on January 14, 2010, 04:37:23 PM
The property you want is ' SetGridLineStyle ', and you have to change it per cell.  Single = 1; Double = 2.

Code: [Select]
(vla-setgridlinestyle ob2 1 1 acHorzBottom 1)

Tim,

How could one get the symbol associated with an enum?

I don't know, except per trial and error, unless they are listed elsewhere.  Maybe in the Arx help?  I'll see if I can find anything.
Title: Re: [Help] Table Gridlines
Post by: nivuahc on January 14, 2010, 04:37:41 PM
Code: [Select]
Command: (vla-GetGridLinestyle TblObj 0 1 acHorzBottom)
2

Command: (vla-GetGridLinestyle TblObj 1 1 acHorzBottom)
1

Command: (vla-GetGridLinestyle TblObj 1 1 acHorzTop)
2

Command: (vla-SetGridLinestyle TblObj 2 1 acHorzBottom 2)

Bingo Bango!  :lol:
Title: Re: [Help] Table Gridlines
Post by: T.Willey on January 14, 2010, 04:44:02 PM
I was faster... I won!!!  :lol:

Edit:
Tim,

How could one get the symbol associated with an enum?

I had to use reflector, but the enums are not the same as what was shown, but the ones from reflector work.
Example
4 = acHorzBottom
Code: [Select]
(vla-setgridlinestyle ob2 1 1 4 1)

Edit2:
Found this in one of the arx docs, for GridLineType
Quote
AllGridLines = 0x3f  All grid line types 
HorizontalBottom = 4  The top or bottom horizontal grid line of the table, depending on flow direction. 
HorizontalGridLines = 7  Outer grid line types 
HorizontalInside = 2  All horizontal grid lines, excluding the top and bottom lines. 
HorizontalTop = 1  The top or bottom horizontal grid line of the table, depending on flow direction. 
InnerGridLines = 0x12  Inner grid line types 
InvalidGridLine = 0  Invalid. 
OuterGridLines = 0x2d  Outer grid line types 
VerticalGridLines = 0x38  Vertical grid line types 
VerticalInside = 0x10  All vertical grid lines, excluding the ones on the far left and far right of the table. 
VerticalLeft = 8  The grid line at the far left of the table. 
VerticalRight = 0x20  The grid line at the far right of the table. 
Title: Re: [Help] Table Gridlines
Post by: Lee Mac on January 14, 2010, 04:53:11 PM

Edit:
Tim,

How could one get the symbol associated with an enum?

I had to use reflector...

What is reflector?
Title: Re: [Help] Table Gridlines
Post by: T.Willey on January 14, 2010, 04:55:33 PM
Code: [Select]
Command: (vla-GetGridLinetype TblObj 0 1 acHorzBottom)
2128841888

Just to finish this up, the code posted above will get the LineType ObjectId of the cell specified.
Example
Code: [Select]
Command: (vlax-invoke actdoc 'objectidtoobject (vla-getgridlinetype ob2 1 1 4))
#<VLA-OBJECT IAcadLineType 1a6a555c>
Title: Re: [Help] Table Gridlines
Post by: T.Willey on January 14, 2010, 04:57:37 PM

Edit:
Tim,

How could one get the symbol associated with an enum?

I had to use reflector...

What is reflector?

It's a program used to disassemble program files, dll exe, so that you can see what is available to use with that.  I may not be totally correct there, but that is what it does in my mind.   :-)

http://www.red-gate.com/products/reflector/
Title: Re: [Help] Table Gridlines
Post by: Lee Mac on January 14, 2010, 04:58:52 PM
Code: [Select]
Command: (vla-GetGridLinetype TblObj 0 1 acHorzBottom)
2128841888

Just to finish this up, the code posted above will get the LineType ObjectId of the cell specified.
Example
Code: [Select]
Command: (vlax-invoke actdoc 'objectidtoobject (vla-getgridlinetype ob2 1 1 4))
#<VLA-OBJECT IAcadLineType 1a6a555c>

Ahh, did not know that - so what I said above was a load of rubbish then  :oops:
Title: Re: [Help] Table Gridlines
Post by: T.Willey on January 14, 2010, 05:09:55 PM
Code: [Select]
Command: (vla-GetGridLinetype TblObj 0 1 acHorzBottom)
2128841888

Just to finish this up, the code posted above will get the LineType ObjectId of the cell specified.
Example
Code: [Select]
Command: (vlax-invoke actdoc 'objectidtoobject (vla-getgridlinetype ob2 1 1 4))
#<VLA-OBJECT IAcadLineType 1a6a555c>

Ahh, did not know that - so what I said above was a load of rubbish then  :oops:

I only learned it cuz I read the help files, and thought that method sounded wrong for what the OP wanted.
Title: Re: [Help] Table Gridlines
Post by: Lee Mac on January 14, 2010, 05:56:58 PM
Code: [Select]
Command: (vla-GetGridLinetype TblObj 0 1 acHorzBottom)
2128841888

Just to finish this up, the code posted above will get the LineType ObjectId of the cell specified.
Example
Code: [Select]
Command: (vlax-invoke actdoc 'objectidtoobject (vla-getgridlinetype ob2 1 1 4))
#<VLA-OBJECT IAcadLineType 1a6a555c>

Ahh, did not know that - so what I said above was a load of rubbish then  :oops:

I only learned it cuz I read the help files, and thought that method sounded wrong for what the OP wanted.

Nice one :-)

To be honest, I don't like the Table functions, I'm not sure why ADesk didn't stick to the standard vla-put-Something/vla-get-Something, instead of vla-getSomething/setSomething...

Lee
Title: Re: [Help] Table Gridlines
Post by: T.Willey on January 14, 2010, 06:00:34 PM
I think they had to do it that way.  Too many parameters otherwise.  With ' vla-put-.... ' you only have one option, but with some many cells, you have to tell it which cell, unless they went with like a cell collection, and then you might be able to have only one option, but like this one, you still have four options once it's a cell.

/thinking out loud...
Title: Re: [Help] Table Gridlines
Post by: nivuahc on January 15, 2010, 07:53:40 AM
Still, it would be nice if it had formatting options for an entire row or column, like in this instance. Unless I'm missing something, the only such options available are SetColumnName SetColumnWidth & SetRowHeight.  :|