Jump to content

add options to create a new TableStyle lisp


hosneyalaa

Recommended Posts

Hello all

 

I found a code to create a newStyle  for the table

On this page

https://forums.augi.com/showthread.php?47551-How-to-create-a-new-TableStyle

 

this lisp 

(defun C:tryit (/ acmcol adoc clsname keyname
		newstyleobj tbldict tblstylename)
  (vl-load-com)
  (or adoc
      (setq adoc
	     (vla-get-activedocument
	       (vlax-get-acad-object)
	     )
      )
  )
  (setq	tbldict
	 (vla-item
	   (vla-get-dictionaries
	     (vla-get-database adoc)
	   )
	   "Acad_TableStyle"
	 )
  )
  ;; look in the tablestyle dictionary to search for our style name:
  (if (vl-catch-all-error-p
	(setq tbstyleObj (vl-catch-all-apply
			   (function (lambda()
  				       (vla-item tbldict "TblStyleName"))))));change table style name here
    ;; if table style "TblStyleName" does not exist:
  (progn
  (setq	keyname	     "NewStyle"
	clsname    "AcDbTableStyle"
	tblstylename "TblStyleName" ;change table style name here
  )
  (setq	newstyleobj
	 (vlax-invoke tbldict 'Addobject keyname clsname)
  )
  (setq	acmcol (vla-GetInterfaceObject
		 (vlax-get-acad-object)
		 (strcat "AutoCAD.AcCmColor." (itoa (atoi(getvar "acadver"))))
	       )
  )
  (vlax-put acmcol 'Colorindex 121)
  (vlax-put newstyleobj 'Name TblStyleName)
  (vlax-put newstyleobj 'Description "Your description here")
						  ;or use style name as the description
  (vlax-put newstyleobj 'HorzCellMargin 0.06)
  (vlax-put newstyleobj 'VertCellMargin 0.06)
  (vlax-put newstyleobj 'TitleSuppressed :vlax-false)
  (vlax-put newstyleobj 'HeaderSuppressed :vlax-false)
  (vlax-invoke newstyleobj 'SetColor acDataRow acmcol)
  (vlax-invoke newstyleobj
	    'SetBackgroundColorNone
	    acDataRow
	    :vlax-false
  )
  (vlax-invoke newstyleobj 'SetTextStyle acDataRow "Standard");change textstyle name here
  (vlax-invoke newstyleobj 'SetTextHeight acTitleRow 0.25)
  (vlax-invoke newstyleobj 'SetTextHeight acHeaderRow 0.2)
  (vlax-invoke newstyleobj 'SetTextHeight acDataRow 0.18)
  (vlax-invoke newstyleobj 'SetGridVisibility acVertInside acDataRow :vlax-true)
  (vlax-invoke newstyleobj
	    'SetAlignment
	    acDataRow
	    acMiddleCenter
  )
  ;| ETC  add another options here|;
  )
    ;;inform user if style exist:
    (princ "\n\t\t ***\tStyle already exist\t***")
    )
  (princ)
)

How to add an options to  this lisp 

As shown in the attached picture
About the red line

Activation DoubleLine 

give DoubleLineSpacing 0.5

Activate borders from all sides

 

Thanks in advance

 

 

 

 

 

 

Capture.PNG

Link to comment
Share on other sites

Just a guess start googling SetDoubleline acDataRow tables are a bit like Dims so many variables.

 

This took 30 seconds and look at where the answer is.

 

Edited by BIGAL
  • Thanks 1
Link to comment
Share on other sites

Thank you very much  BIGAL 

I saw the subject and worked lisp  for him

Modifying an existing table only works

I wanted to add this feature to the lisp above

Without the need for modification

 

(defun DLT (tbl / rws #columns z x  )
(and       (setq rws (vla-Get-Rows tbl))
               (setq #columns (vla-get-Columns tbl))   
     );; and
 (setq x 0)
 (setq Z 0)
 (repeat rws
 (repeat #columns
(vla-SetGridDoubleLineSpacing tbl X Z (+ acHorzBottom acHorzTop acVertLeft acVertRight) 0.2)
(vla-setgridlinestyle tbl X Z (+ acHorzBottom acHorzTop acVertLeft acVertRight) acgridlinestyledouble)
  (setq Z (+ Z 1)))
  (setq Z 0)
    (setq x (+ x 1))
  )
)

If there is no solution or idea

 

thank you to everyone

 

 

Link to comment
Share on other sites

5 hours ago, BIGAL said:

Just a guess start googling SetDoubleline acDataRow tables are a bit like Dims so many variables.

 

This took 30 seconds and look at where the answer is.

 

I saw that thread as well. The issue is the OP was asking how to apply that double line to the TABLESTYLE not the TABLE :)

  • Thanks 1
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...