Creating a line within a table

Creating a line within a table

david_norrisHJ9DY
Contributor Contributor
682 Views
7 Replies
Message 1 of 8

Creating a line within a table

david_norrisHJ9DY
Contributor
Contributor

Hi all,

 

I have got this code which adds up lines and hatches only if layer descriptions are present. This is the result:

 

david_norrisHJ9DY_0-1702646367036.png

 

Really happy with it, the hatch part is totally fine. My only issue is that I would want a line to represent the polylines in the first column so it would look like this:

david_norrisHJ9DY_1-1702646461956.png

Is there a way to do this? 

 

This is the section of my code that processes the polylines:

 

; Process polylines
(if (setq ss (ssget '((0 . "POLYLINE,LWPOLYLINE"))))
(progn
(setq AllData nil
ssNH (ssadd)
)

(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(setq layer (vlax-get e 'Layer))
(setq description (vla-get-description (vla-item (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) layer)))

(if (and description (not (equal description "")))
(progn
(setq edata
(list
layer
(if (not (vl-catch-all-error-p
(setq length_ (vl-catch-all-apply 'vla-get-length (list e)))
)
)
length_
(progn
(ssadd (ssname ss i) ssNH) 0.0
)
)
)
)
(setq AllData
(if (setq f (assoc (car edata) AllData))
(subst (list (car f) (+ (cadr f) (cadr edata)) (1+ (caddr f))) f AllData)
(cons (append edata (list 1)) AllData)
)
)
)
(progn
(princ)
)
)
)

(setq AllData (vl-sort AllData '(lambda (m n) (< (car m) (car n)))))

(foreach d AllData
(vla-insertrows Area_table
(1+ (setq crow (vla-get-rows Area_table)))
(* 1500 0.004) ; Scale row height
1
)
(vla-setcelltextheight Area_table crow 0 (* 500.0 0.004)) ; Scale text height
(vla-setCellAlignment Area_table crow 0 5)

; Set Color (first column)
(setq x (strcat "AutoCAD.AcCmColor." (substr (getvar 'Acadver) 1 2)))
(setq clr (vlax-create-object x))
(vla-put-colorindex clr (vla-get-color (vla-item (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (car d))))
(vla-SetCellBackgroundColor Area_table crow 0 clr)

; Set Category (second column)
(vla-setCellValue Area_table crow 1 (vla-get-description (vla-item (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) (car d))))
(vla-setcelltextheight Area_table crow 1 (* 500.0 0.004)) ; Scale text height
(vla-setCellAlignment Area_table crow 1 5)

; Set Length (third column)
(vla-setCellValue Area_table crow 2 (rtos (cadr d) 2 2)) ; Convert length to string with 2 decimal places
(vla-setcelltextheight Area_table crow 2 (* 500.0 0.004)) ; Scale text height
(vla-setCellAlignment Area_table crow 2 5)
(vla-setcellformat Area_table crow 2 "%lu2%pr1%ps[, m]%ct8[1.000000000000000E-006]")
)

)
)

(princ)

 

0 Likes
683 Views
7 Replies
Replies (7)
Message 2 of 8

pendean
Community Legend
Community Legend

You can't embed line/plines/blocks into table cells yet, Autodesk has not opened up that ability: unlike table cell background colors (you're calling them hatches)

pendean_0-1702649840517.png

 

You could perhaps use an old trick of splitting your one cell into two or more cells and allowing for the "middle" like to be visible I suppose, I've not tried it.

0 Likes
Message 3 of 8

david_norrisHJ9DY
Contributor
Contributor

Hi there,

 

Ahhhh okay, if I can't embed lines into a table, I can't do it I guess.

Just thinking out loud, is it possible to just have a line that is just simply in the area of the first column? So for example where it says house, instead of the colour of the line that's represented, a line is just overlayed on top?, it doesn't necessarily need to be embedded in the cell

 

Otherwise that is what I will just do this manually. 😉

 

Thanks for the reply 🙂

0 Likes
Message 4 of 8

pendean
Community Legend
Community Legend

@david_norrisHJ9DY you can float anything you want over any cell, it will just never adjust it's position as your cells or table move or resize.

0 Likes
Message 5 of 8

david_norrisHJ9DY
Contributor
Contributor

Could this be done via autolisp?

0 Likes
Message 6 of 8

Michiel.Valcke
Advisor
Advisor

Yes you can,

To make a block definition you entmake a block, then entmake your geometry and then entmake the block end. Then to insert the block definition you entmake an insert.

 

    (entmake
      (list
        (cons 0 "BLOCK")
        (cons 2 "Blockname")
        (cons 10 (list 0.0 0.0 0.0)) ; the origin point inside your block.
        (cons 70 0) 
      )
    ) ; this starts making the block definition.
    (entmake
        (list
          (cons 0 "LINE")
          (cons 100 "AcDbEntity")
          (cons 10 pt1)
          (cons 11 pt2)
        )
    ); you can make as much geometry here as you want
    (entmake
      (list (cons 0 "ENDBLK"))
    ); this finishes the making of your block definition.

; this make the blockreference you just need to know the name of the block and the point where you want to place it. You can add other DXF codes for rotation or scale.
  (entmake (list
             (cons 0 "INSERT")
             (cons 8 "0")
             (cons 100 "AcDbEntity")
             (cons 100 "AcDbBlockReference")
             (cons 2 "Blockname")
             (cons 10 (insertionpoint))
           )
  )

 

Or you can just make the geometry you want (a line directly) on top of the cell you just need to figure out the cell's position.

 

Message 7 of 8

MrJSmith
Advocate
Advocate

Couldn't you use an object reactor to keep the line in the determined cells position, so if you were to move the table the line would update and move with it?

0 Likes
Message 8 of 8

Sea-Haven
Mentor
Mentor
0 Likes