Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert block cancels on me

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
277 Views, 3 Replies

Insert block cancels on me

Hi, I'm fairly new to visual lisp editor and I'm testing out a simple code that  finds an area of a closed polygon, creates a block attribute and inserts it with the new value:

(defun c:P_blocks(/ s a sqft area)
  (setq s (car (entsel)))
  (setq s (vlax-ename->vla-object s))
  (setq a (vla-get-area s))
  (setq sqft (/ a 144))
  (entmake '((0 . "block")
           (2 . "room")
           (10 0.0 0.0 0.0)
           (70 . 2)
          ))	   
  (entmake 
    '((0 . "ATTDEF")
      (1 . "area");value
      (2 . "room");Tag string (cannot contain spaces)
      (3 . "square footage ??");Prompt string
      (8 . "wall");layer
      (10 0.3 4.3 0.0 ) ;First alignment point 
      (40 . 2.0);
      (41 . 1.0)
      (50 . 0.0)
      (70 . 0)
      (71 . 0)
      (72 . 0)
      (73 . 2))
  )
  (entmake '((0 . "endblk")))
  
  (entmake (list
      '(0 . ".-insert")
      '(8 . "wall")
      '(2 . "room")
      '(10 0.0 0.0 0.0)
       (cons 1 (rtos sqft 2 2))
      '(41 . 1)
      '(42 . 1)
      '(50 . 0.0)
      ))

  )

 every line leading up to the "insert" routine works as follows, but when i run it, i get:

 

Redefining block "room"
*Cancel*
nil

 

Any Ideas would be much appreciated.

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Wish I could help but I'm not any good with lisp. 

 

You might have better luck if you posted in the lisp forum though.

 

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/bd-p/130

 

 

Message 3 of 4
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:

....

....
  (entmake (list
      '(0 . ".-insert")
....
       (cons 1 (rtos sqft 2 2))
....

 ....


I rarely deal with (entmake), but I see a couple of things....

 

The period and hyphen preceding the word insert may be appropriate with a command name, but are not appropriate in an entity type name.  Try it just the way it appears if you (entget) a Block insertion:

 

'(0 . "INSERT")

 

The value of the text content of an Attribute is not an element of the Block insertion's entity data -- the Attribute is a separate entity.  [After all, a Block can have more than one Attribute, so to which of them would it assign that value?]  I'm not sure exactly how to handle that in (entmake), but I would just use (command "_.insert" ... and feed in the Attribute's text content at the end after the scale and rotation entries.  [That would also eliminate the issue in my first comment.]

Kent Cooper, AIA
Message 4 of 4
Anonymous
in reply to: Kent1Cooper

this is true, I was successful in just simply using  (command ".-insert" ... sqft)  I was just curious to see if it was possible to create the same result in (entmake). Thank you for the insight! 

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report