Jump to content

How can I make this insert at the right scale?


BLOACH85

Recommended Posts

Ok so, I see it has this:

 

;   SetScale (4)

 

So I take it that you can use something like the following:

 

 

vlax-invoke-method tb 'SetScale... [4 arguments]
vla-SetScale tb [4 Arguments]

 

from the number in brackets, one can tell that this method takes 4 arguments, which will need to be included for it to work.

Link to comment
Share on other sites

  • Replies 51
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    24

  • BLOACH85

    21

  • fixo

    7

Top Posters In This Topic

well i have allready talked to fixo but i guess he forgot to throw that little bit in there. So you say 4 arguments as in back to back or in diff places?

Link to comment
Share on other sites

it said it was password protected and im starting to see that im about waist high in something and sinking fast. Im just lost!:?

 

 

OK, I think its time to leave it to the professionals! :)

 

I'm also lost at this point - (as if I wasn't before...)

 

I have tried to advise as much as I can - using the Developer's Bible and the little knowledge I have of Visual LISP - but, as I can't even test the function on my machine (being on '04) I'm a bit helpless at this point.

Link to comment
Share on other sites

Hopefully someone like ASMI, CAB or Fixo will shed some light on the situation - but I hope I've been of some help all the same.

 

Cheers

 

Lee

That's out of my lisp skills unfortunately

I have not found any docs for this function

Here is what I have so far

As you see nothing happened and I don't know

what the 'vla-setcale' does

(defun C:STUBS	(/ col count dis dmz lpc lup pt row strdis tb va vm vo)
 
 (setq pt (vlax-3d-point (getpoint "\nPick Insertion Point: ")))
 (setq vo (vlax-get-acad-object))
 (setq va (vla-get-activedocument vo))
 (setq vm (vla-get-modelspace va))
 (setq row 16)
 (setq col 1)
 (setq dis (getdist "\nWhat Is The First Stub Dimension? : "))
 (setq lup (getvar "lunits"))
 (setvar "lunits" 4)				  ; architectural units
 (setq lpc (getvar "luprec"))
 (setvar "luprec" 4)				  ;precision 1/16"
 (setq dmz (getvar "dimzin"))
 (setvar "dimzin" 1)				  ;includes both feet and inches for primary unit 

 (setq strdis (rtos dis 4 3))
 (setq tb (vla-addtable vm pt row col 1 1))
 (vla-put-titlesuppressed tb :vlax-false)
 (vla-put-headersuppressed tb :vlax-true)
 (vla-put-RegenerateTableSuppressed tb :vlax-true)
 
 (vla-put-vertcellmargin tb 0.1)
 (vla-put-horzcellmargin tb 0.25)
 (vla-setrowheight tb 0 0.4825)
 (vla-setcolumnwidth tb 0 2.725)

 (vla-settextstyle tb actitlerow "Romans")	  ;title text style
 (vla-settextstyle tb acdatarow "Standard")	  ;data rows text style
 (vla-settextheight tb actitlerow 0.27)	  ;title text height = 0.27
 (vla-settextheight tb acdatarow 0.21)		  ;other cells text height = 0.21
 (vla-setalignment tb actitlerow acmiddlecenter) ;title alignment
 (vla-setalignment tb acdatarow acmiddleleft)	  ;data cell alignment
 (vla-settext tb 0 0 "STUBS")			  ;title text

 (setq count 1)

 (while (< count row)
   (vla-setrowheight tb count 0.3875)
   
   (if	(= count 1)
     (progn
     (vla-setcelltype tb count 0 acTextCell);optional, but pedantic
     (vla-settext tb count 0 strdis)
     (vla-setcellformat tb count 0 "%lu4%pr4");lu4 - format in architectural units, pr4 - precision is 1/16"
     (vla-setscale tb count 0 0 2.0);; (arguments: table object, row #,column #, CellContentType constant, scale)
     )
     (progn
     (vla-setcelltype tb count 0 acTextCell);optional, but pedantic
     (vla-settext tb count 0 (strcat "= A2*" (itoa count)));lu4 - format in architectural units, pr4 - precision is 1/16"
     (vla-setcellformat tb count 0 "%lu4%pr4")
     (vla-setscale tb count 0 0 2.0)
)
     )

   (setq count (1+ count))
   )
 
 (vla-put-RegenerateTableSuppressed tb :vlax-false)
 
 (vla-update tb)
 (vl-cmdf "._zoom" "_O" (entlast) "")
 (alert 
   (strcat "Scale of the last cell is: "
	   (vl-princ-to-string(vla-getscale tb (1- count) 0 0))
 "\nValue of the last cell is: "
	   (vl-princ-to-string 
	     (vlax-variant-value
	       (vla-getcellvalue tb (1- count) 0)))
	     "''"
	     ))
 (setvar "luprec" lpc)
 (setvar "lunits" lup)
 (setvar "dimzin" dmz)
 (princ)
 ) ;_ end
(vl-load-com)

 

~'J'~

Link to comment
Share on other sites

I scoured the net also looking for docs on the function - it seems that it is listed, but no additional information is given regarding its returns, arguments, etc etc.

Link to comment
Share on other sites

Here is a snip from ObjectARX SDK docs:

setScale(

int row,

int col,

int nContent);

row Input row index. It should be more than or equal to 0 and less than the number of rows. 
col Input column index. It should be more than or equal to 0 and less than the number of columns. 
nContent Input content index. It should be more than or equal to 0 and less than the number of contents. 

Sets the scale of the content at the specified content index.

Returns Acad::eOk if successful; otherwise, returns an AutoCAD error status.

 

~'J'~

Link to comment
Share on other sites

Thats interesting that it appears in that documentation to take only three arguments, when, in the list of supported methods, SetScale seems to require (4). :huh:

 

But as I say, I am still very new to this Visual LISP, and have much to learn.

Link to comment
Share on other sites

Thats interesting that it appears in that documentation to take only three arguments, when, in the list of supported methods, SetScale seems to require (4). :huh:

 

But as I say, I am still very new to this Visual LISP, and have much to learn.

 

No, this function require 4 arguments,

the first argument of these in my lisp

is 'tb' (table vla-object)

 

~'J'~

Link to comment
Share on other sites

So If this method is not used usually then maybe there is and easier way? But i guess also if the is 4 arguments then you also have to find the right place to put them huh?

Link to comment
Share on other sites

Yes, I would assume that the arguments would need to be in a certain order.

 

 

But, I am not sure of the result of this function "addtable" so, finding an alternative may be difficult. :)

Link to comment
Share on other sites

this came from

 

http://management.cadalyst.com/cadman/Column:++AutoLISP+Solutions/Convert-Old-Table-Data-to-New-Table-Format-AutoLIS/ArticleStandard/Article/detail/494399

 

 

 

 

 

Programming Notes

After my usual error and system variable management functions, the program starts with the GETOLDTABLE function that uses the VLA-GETPOINT and VLA-GETCORNER methods to establish two diagonally opposite points that are used to select the table entities. The points are actually used twice: once to select any polylines that may exist and again to select all lines and text objects. If any polylines are found, they are exploded via the VLA-EXPLODE method. GETOLDTABLE concludes by creating a selection set of the lines and text objects, then calling MAKETABLE using the selection set as its argument.

 

MAKETABLE collects the lines and text in separate lists via calls to GET-LINES and GET-TEXT. The lines are further separated into horizontal and vertical lines via calls to GET-ROWSCOLS before being sorted into lists of rows and columns. In case there are duplicate lines, the lists of rows and columns are refined by the DO-DUPES function before being sorted again. The text objects are separated into multiline text and single-line text lists via calls to GET-TXTMTXT. The parameters for the VLA-ADDTABLE method are the number of rows and columns and the row height and column width. The table object is then created as an empty table by the following code:

(setq tableobj (vla-AddTable *modelspace* (vlax-3D-point (caar collines3)) rows cols RowHeight ColWidth ) ;_ end of vla-AddTable ) ;_ end of setq

The default table has a header and a title, and I opted to take out the merging for the title row and place the table object on the layer of the original text objects. Then it's time to populate the table cells by a call to POPULATE-TABLE as follows:

(vla-UnmergeCells tableobj 0 0 0 (- cols 1)) (setq lyr (vla-get-Layer (nth 0 horlines))) (vla-put-layer tableobj lyr) (populate-table tableobj tlist rowlines3 collines3)

One of the more interesting functions in the above is DO-DUPES, which should be fairly straightforward because there is a great Visual LISP function (VL-REMOVE) that purports to remove any item (and its duplicates) from a list. Unfortunately, in this case the method did not work consistently on lists of points because the coordinates were not exact enough, even though the lines were exactly on top of each other to within 13 decimal places! Instead, after wasting much time wondering why the duplicate lines were not being removed, I wrote my own version of the remove method (MYVL-REMOVE):

(defun myvl-remove (item llst) (setq j (- 1)) (repeat (length llst) (setq item2 (nth (setq j (1+ j)) llst)) (if (equal item item2 fuzz) (setq llst (vl-remove item2 llst)) ) ;_ end of if ) ;_ end of repeat llst ) ;_ end of myvl-remove

The solution here was to include a fuzz factor to test equality, then to remove the actual item compared in the list, shown here as ITEM2. This method only guarantees to remove one duplicated item at a time, but it tests every item in the list, so it takes care of any number of duplicates. I usually designate global variables by starting and ending them with asterisks, but in the above, the FUZZ variable does not conform to that format. In fact, throughout this particular program, I have not designated local and global variables at all except those that are passed as arguments. Programming in this way can be risky, but I opted to initialize lists and counters in the separate functions instead.

The POPULATE-TABLE function relies on taking each text object in turn from a text list and using its insertion point to determine where (which row and column) it should be placed in the new table. This is a reasonable approach for tables that are not completely full of text because the empty cells are simply not considered. All header text objects are in Row 0 (the top row), and that made it easy to deal with them. The columns for the header text were determined by the locations of the merged cells. All other text objects are placed using the VL-SETTEXT method, then the cell parameters are set for cell height, column width, text style, and text height. The code fragment for this is:

(progn (vla-SetText tobj row col txtstr) ) ;_ end of progn ) ;_ end of if (vla-SetCellTextHeight tobj row col txtht) (vla-SetColumnWidth tobj col colwidth) (vla-SetRowHeight tobj row rowheight) (vla-SetCellTextStyle tobj row col textstyle)

When tables are created they start off empty, then cells are formatted and text is added. Each time this is done, the table is automatically regenerated, so I advise that you hold off on regeneration until all cells are completed. The regeneration is designated as true or false, and the following code taken from the MAKETABLE function shows how this has been done:

(vla-put-RegenerateTableSuppressed tableobj :vlax-True) (vla-UnmergeCells tableobj 0 0 0 (- cols 1)) (setq lyr (vla-get-Layer (nth 0 horlines))) (vla-put-layer tableobj lyr) (populate-table tableobj tlist rowlines3 collines3) (if (> cols 6) (progn (vla-MergeCells tableobj 0 0 0 5) (vla-MergeCells tableobj 0 0 6 7) ) ;_ end of progn (vla-MergeCells tableobj 0 0 0 (- cols 1)) ) ;_ end of if (vla-put-RegenerateTableSuppressed tableobj :vlax-False) (vla-erase ss1) ) ;_ end of MakeTableThe last line of this function erases the entire selection set of lines and text that make up the original table.

Link to comment
Share on other sites

This comes from

 

 

http://cadpanacea.com/node/73

 

Create a TABLE using lisp

 

Mon, 08/13/2007 - 06:44 — rkmcswain Here is an example of creating a TABLE entity using lisp. This example also creates some FIELDS using lisp.

This routine allows the user to select closed polylines, and it will create a TABLE with two columns. One containing the area, and the other containing the ObjectID. The last row totals up the area. You could easily adapt this to show the layer, color or any other property.

The TABLE is creating on the current tablestyle, so depending on the settings of your current tablestyle, you may have to adjust the sizing arguments in the (vla-addTable...) function in order for the table to look acceptable. These sizes used here work with the Standard tablestyle in a new empty drawing.

 

 

 

[color=darkred]; load (vl-load-com) first[/color](vl-load-com)(defun C:POLYTABLE ( / *MS* A CNT I LST MYTABLE PT1 ROW SSET TLST)[color=darkred]  ; create an empty list, set a counter variable, and  ; set a reference to the current model space.[/color]  (setq lst '() i 0 *ms* (vla-get-modelspace             (vla-get-activedocument             (vlax-get-acad-object)))  )  [color=darkred]; prompt the user to select closed polylines[/color]  (princ "\n Select closed polylines ")  (if (setq sset (ssget '((0 . "POLYLINE,LWPOLYLINE")(-4 . "&")(70 . 1))))    [color=darkred]; if a valid selection set was generated, then proceed.[/color]    (progn    [color=darkred]      ; for each closed polyline selected, grab the ObjectID and Area      ; and store these values in a list.[/color]      (repeat (setq cnt (sslength sset))        (setq a (vlax-ename->vla-object (ssname sset i)))        (setq tlst (list (vla-get-Area a) (vla-get-ObjectID a)))        (setq lst (cons tlst lst))        (setq i (1+ i))      )[color=darkred]      ; pick a point for the table[/color]      (setq pt1 (getpoint "\nPick point for table "))[color=darkred]      ; add the new table[/color]      (setq myTable (vla-AddTable                     *ms*                     (vlax-3d-point pt1)                    (+ 3 cnt)                    2                     0.7                    2.5))[color=darkred]      ; the next three lines set the header text[/color]      (vla-setText mytable 0 0 "Polyline Table")      (vla-setText mytable 1 0 "Area")      (vla-setText mytable 1 1 "Object ID")      (setq row 2)[color=darkred]            ; loop through the list of polyline properties      ; adding a line to the table that contains the      ; area and the ObjectID[/color]      (foreach item lst        (vla-setText mytable                     row                     0                      (strcat "%<\\AcObjProp Object(%<\\_ObjId "                     (itoa (last item))                     ">%).Area \\f \"%lu2\">%"))        (vla-setText mytable row 1 (last item))        (setq row (1+ row))      )      [color=darkred]      ; On the last row, total up the area[/color]      (vla-setText mytable                   row                    0                   (strcat "Total=\\P"                   "%<\\AcExpr (Sum(A3:A" (itoa (+ 2 cnt)) ")) \\f \"%lu2\">%"))[color=darkred]      ; release "myTable" and *ms*[/color]      (vlax-release-object myTable)            (vlax-release-object *ms*)          )[color=darkred]; end progn[/color][color=darkred]   ; if no closed polylines were selected,    ; end the program with this message[/color]    (princ "\nNo closed polylines selected. ")  )[color=darkred]; end if[/color]  (princ))[color=darkred]; end defun[/color]

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