Jump to content

Recommended Posts

Posted (edited)

I was trying to append data so that if there is more than one tag under the table, excel would insert it under a new row, but does not seem to work. Any ideas would help!

My basis was @Lee Mac and the lisp "Global Attribute Extractor & Editor".

the table looks like this:

 

 

(defun get-block-attributes (block)
    (setq attr-list (LM:getattributevalues block))
    (setq result '())
    (foreach attr attr-list
      (let ((tag (car attr)) (value (cdr attr)))
        (if (wcmatch tag "R-TECH*")
          (setq result (append result (list (list tag value)))))))
    result)
 (if selection
    (progn
      (setq workbook (vlax-invoke-method (vlax-get-property excel 'Workbooks) 'Add))
      (setq sheet (vlax-get-property (vlax-get-property workbook 'Sheets) 'Item (vlax-make-variant 1 vlax-vbInteger)))

      (setq row 1)
      (repeat (sslength selection)
        (setq ent (ssname selection (setq idx (1+ idx))))
        (setq blk (vlax-ename->vla-object ent))
        (setq attributes (get-block-attributes blk))
        
        ;; Debugging information
        (princ (strcat "\nProcessing block: " (vla-get-Name blk)))
        
        (foreach attr attributes
          (let ((tag (car attr)) (value (cadr attr)))
            ;; Debugging information
            (princ (strcat "\nWriting to Excel - Tag: " tag " Value: " value))
            
            (write-to-excel sheet row 1 (vla-get-Name blk))
            (write-to-excel sheet row 2 tag)
            (write-to-excel sheet row 3 value)
            (setq row (1+ row))))))
    (alert "No blocks selected."))

 

Edited by Sambuddy
Posted

Post a dwg it looks like just rearrange the way the table is made. Make sure it has a correct table in it row & column sizes etc.

Posted (edited)
On 07/08/2024 at 19:54, BIGAL said:

Post a dwg it looks like just rearrange the way the table is made. Make sure it has a correct table in it row & column sizes etc.

I am not using an AutoCAD standard table, if that is what you mean. it is a bunch of lines and text attributes turned to a block.

This block is then replicated as many times as required to makeup the entire table. Reason: sometimes there is one technology (R-TECH1) and sometimes multiple technology for a specific antenna specs, hence the need for this block to remain as a dynamic block with multiple visibilities. You then would copy and paste the block to fill up the other antennas on this table.

 

Edited by Sambuddy
Posted

Still post a sample dwg very hard to fudge something that matches what you have. Yes can export to Excel direct.

Posted (edited)
On 08/08/2024 at 20:15, BIGAL said:

Still post a sample dwg very hard to fudge something that matches what you have. Yes can export to Excel direct.

Please see the dwg sample @BIGAL

 

Edited by Sambuddy
Posted (edited)

It may not be straight forward as your using 2 types of blocks to make the quasi "Table" will have to think about it. The Type and Equipmet blocks.

Edited by BIGAL
Posted

@BIGAL Please do not break your head over this, I am not using VBA to update my data once transferred. I created a bunch of functions to sort them nce they are in excel space so no need to manipulate data on lisp. Thanks for your response anyways!

Posted (edited)

I don't have a problem working with say block or text in rows and columns the problem is in the 2 blocks and acting as merged cells. Need to almost rebuild a new copy that can be defined in Excel. May need to use a bounding box to find objects at some X or Y value.

 

Moved it up in my To do list. Got a commercial problem to solve 1st.

 

Thinking more it may be easier to just write new code to make it a Table. 

Edited by BIGAL

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