Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Access block editor in table, right click etc

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
robert06
2113 Views, 10 Replies

Access block editor in table, right click etc

Has anyone made a customization to access block editor in table (table cell containing a block)?

Could be a command, a right click choice etc. By default, without such shortcut, you will firstly need to check the block name that is inserted by clicking the table cell, then run Bedit and scroll down to find the block.

 

thanks

10 REPLIES 10
Message 2 of 11
Lee_Mac
in reply to: robert06

Try the following:

 

;; Table Block Edit  -  Lee Mac
;; Opens the block associated with a selected table cell in the Block Editor

(defun c:tbedit ( / *error* cel def idx lst sel )

    (defun *error* ( msg )
        (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
            (princ (strcat "\nError: " msg))
        )
        (princ)
    )
    
    (cond
        (   (null
                (setq sel
                    (ssget "_X"
                        (list '(0 . "ACAD_TABLE")
                            (if (= 1 (getvar 'cvport))
                                (cons 410 (getvar 'ctab))
                               '(410 . "Model")
                            )
                        )
                    )
                )
            )
            (princ "\nNo tables found in current layout.")
        )
        (   (progn
                (repeat (setq idx (sslength sel))
                    (setq lst (cons (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))) lst))
                )
                (while
                    (progn
                        (setq cel (getpoint "\nPick block cell: "))
                        (cond
                            (   (null cel) nil)
                            (   (null (setq cel (LM:getcell lst (trans cel 1 0))))
                                (princ "\nNo cell found at point.")
                            )
                            (   (/= acblockcell (apply 'vla-getcelltype cel))
                                (princ "\nCell does not contain a block.")
                            )
                            (   (vl-catch-all-error-p (setq def (vl-catch-all-apply 'LM:getcellblock cel)))
                                (princ
                                    (strcat
                                        "\nError retrieving block: "
                                        (vl-catch-all-error-message def)
                                    )
                                )
                            )
                        )
                    )
                )
                (= 'vla-object (type def))
            )
            (vl-cmdf "_.bedit" (vla-get-name def))
        )
    )
    (princ)
)

;; Get Table Cell Block  -  Lee Mac
;; Returns the Block Definition associated with a given table cell

(defun LM:getcellblock ( tab row col )
    (eval
        (list 'defun 'LM:getcellblock '( tab row col )
            (if
                (and
                    (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*")
                    (vlax-method-applicable-p tab 'getblocktablerecordid32)
                )
                (list 'vla-objectidtoobject32 (LM:acdoc) '(vla-getblocktablerecordid32 tab row col))
                (list 'vla-objectidtoobject   (LM:acdoc) '(vla-getblocktablerecordid   tab row col))
            )
        )
    )
    (LM:getcellblock tab row col)
)

;; Get Cell  -  Lee Mac
;; If the supplied point lies within a cell boundary,
;; returns a list of: (<VLA Table Object> <Row> <Col>)

(defun LM:getcell ( lst pnt / dir )
    (setq dir (vlax-3D-point (trans (getvar 'viewdir) 1 0))
          pnt (vlax-3D-point pnt)
    )
    (vl-some
       '(lambda ( tab / row col )
            (if (= :vlax-true (vla-hittest tab pnt dir 'row 'col))
                (list tab row col)
            )
        )
        lst
    )
)

;; Active Document  -  Lee Mac
;; Returns the VLA Active Document Object

(defun LM:acdoc nil
    (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object))))
    (LM:acdoc)
)

(vl-load-com) (princ)
Message 3 of 11
hmsilva
in reply to: Lee_Mac

Nicely coded, Lee.

 

Henrique

EESignature

Message 4 of 11
Lee_Mac
in reply to: hmsilva

Thank you Henrique! Smiley Happy

Message 5 of 11
robert06
in reply to: Lee_Mac

Now that's great, many thanks! Smiley Happy

Message 6 of 11
Anonymous
in reply to: robert06

Hi Lee do you have anything like this but for the linetypeTableRecord?

I'd like to check some custom linetypes we've made that have caused issues here and there.

Message 7 of 11
Lee_Mac
in reply to: robert06


@robert06 wrote:

Now that's great, many thanks! Smiley Happy


Thank you Robert, I'm glad you like it! Smiley Happy

Message 8 of 11
Lee_Mac
in reply to: Anonymous


@Anonymous wrote:

Hi Lee do you have anything like this but for the linetypeTableRecord?

I'd like to check some custom linetypes we've made that have caused issues here and there.


Do you mean a program wherein the user would select a line with a custom linetype and the associated .lin file would open in notepad?

 

If so, this may be difficult since, similar to AutoLISP programs, once a linetype is loaded into a drawing, to my knowledge there is no way to trace it back to its linetype definition file - this is compounded by the fact that I believe it is possible to generate custom linetypes in a drawing by using entmake[x] (i.e. without using a .lin file).

 

Lee

Message 9 of 11
Anonymous
in reply to: Lee_Mac

Moreso that we've had errors in our cad system that an audit has pointed to the acdbLinetypetable, was trying to look further into the cause.

Message 10 of 11
robert06
in reply to: Lee_Mac

Hi,

 

I use Lee Mac's 'tbedit' for modifying drawing legend table blocks. To create a new object description in Legend I add new row in the table and copy existing row with similar legend block to the new row (cells) and then modify the new row block cell.

 

It would be excellent having 'tbedit' with a few extra steps. The goal would be editing block in selected table cell and replacing the block in the cell with the new block created in bedit-saveas procedure. The new block name should be based on original block name (with lisped) etc.

 

Is there's a ability to accomplish this, guys?

 

Thank you

 

Message 11 of 11
robert06
in reply to: robert06

How to record the block name as a variablre in Lee's lisp?

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost