Creating a line within a table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I have got this code which adds up lines and hatches only if layer descriptions are present. This is the result:
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:
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)