Help! I need help creating a lisp or macro...

Help! I need help creating a lisp or macro...

Anonymous
Not applicable
899 Views
8 Replies
Message 1 of 9

Help! I need help creating a lisp or macro...

Anonymous
Not applicable

I need the command to:

 

1 Insert a block

2 Find the area, perimeter, and wt/ft (which is just the area * 1.18)

3 Update the block with the information

 

 

I created an action macro that kind of works. However if I have multiple parts, the block updates to the last object selected. I need each part to have its own individual block.

 

Is there a way to insert the area of one object in one block and the area of another object in a second block?

0 Likes
Accepted solutions (1)
900 Views
8 Replies
Replies (8)
Message 2 of 9

ВeekeeCZ
Consultant
Consultant

I guess this task is (multiply) redundant and solved by Henrique here ...

0 Likes
Message 3 of 9

Anonymous
Not applicable

No that other one works well for a drawing with one individual part. But when the drawing has multiple parts, every time the block is inserted, it updates with the area of the last object selected. I need each part to have a block with the area, perimeter, and wt/ft specific to the part.

0 Likes
Message 4 of 9

hmsilva
Mentor
Mentor

@Anonymous wrote:

No that other one works well for a drawing with one individual part. But when the drawing has multiple parts, every time the block is inserted, it updates with the area of the last object selected. I need each part to have a block with the area, perimeter, and wt/ft specific to the part.


Hi Chris,

could you please post a sample dwg with a few parts and blocks.

 

Henrique

EESignature

0 Likes
Message 5 of 9

Anonymous
Not applicable

Here you go Henrique. Thank you.

0 Likes
Message 6 of 9

hmsilva
Mentor
Mentor
Accepted solution

Hello Chris,

I can't see in your code, something that causes 'the block updates to the last object selected'...

 

Try the following quickly-written 'demo':

 

 

(defun c:demo (/ area obj peri pt ss wtft)
   (while (and (princ "\nSelect Quote Part: ")
               (setq ss (ssget "_+.:E:S" '((0 . "REGION"))))
               (setq pt (getpoint "\nEnter Quote insertion point: "))
               (or (findfile "QUOTE.dwg")
                   (tblsearch "block" "QUOTE")
               )
          )
      (setq obj  (vlax-ename->vla-object (ssname ss 0))
            area (vlax-get obj 'Area)
            peri (vlax-get obj 'Perimeter)
            wtft (* 1.18 area)
      )
      (command "-insert" "QUOTE" "_Scale" 1 pt 0
               "_.text" pt "" "" (strcat "Area = " (rtos area)) 0
               "_.text" "" (strcat "Per = " (rtos peri))
               "_.text" "" (strcat "Wt/Ft = " (rtos wtft))
               "_.text" "" (strcat "Length = ")
      )
   )
   (princ)
)

 

 

 

You'll have to select a 'Quote Part' and enter the block insertion point, for each 'Quote Part'.

 

Hope this helps,
Henrique

EESignature

Message 7 of 9

Anonymous
Not applicable

After I choose a block and insertion point, nothing happens. That lisp was developed after I had posted yesterday. That solves the area, perimeter, and wt/ft problem, but now I need to combine that with some sort of block with attributes that has the quote and part number as well as the length. I have a macro that works for one part.

0 Likes
Message 8 of 9

Anonymous
Not applicable

Works great now! Thank you!

0 Likes
Message 9 of 9

hmsilva
Mentor
Mentor

@Anonymous wrote:

Works great now! Thank you!


You're welcome, Chris!
Glad I could help

Henrique

EESignature

0 Likes