Enter Attibutes with lsp in CAD 2018

Enter Attibutes with lsp in CAD 2018

Anonymous
Not applicable
1,341 Views
11 Replies
Message 1 of 12

Enter Attibutes with lsp in CAD 2018

Anonymous
Not applicable

I had created lsp in CAD 2012. Last line for lsp is insert block and fill one attribute. It inserts block, but attribute to fill do not works in 2018:

(command "insert" "TRT-EXT" p6 (* 1 lts) "" "" "UR" "" "" "" "")

 

Autocad text window shows:

Command: insert Enter block name or [?] <TRT-EXT>: TRT-EXT
Units: Unitless Conversion: 1.0000
Specify insertion point or [Basepoint/Scale/X/Y/Z/Rotate]:
Enter X scale factor, specify opposite corner, or [Corner/XYZ] <1>: 1 Enter Y scale factor <use X scale factor>:
Specify rotation angle <0>: *Invalid*
; error: Function cancelled

0 Likes
Accepted solutions (2)
1,342 Views
11 Replies
Replies (11)
Message 2 of 12

TheCADnoob
Mentor
Mentor

id hop over to the customization forum and ask there if you dont get a suitable answer here

 

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

CADnoob

EESignature

0 Likes
Message 3 of 12

Ranjit_Singh
Advisor
Advisor

I do not have 2018 but you can walk through the insert (or -insert) command and see what input it needs. Just start the insert command at command prompt and note down the sequence of inputs. Make sure your lisp code follows the exact responses.

 

0 Likes
Message 4 of 12

SeeMSixty7
Advisor
Advisor

Your command echo makes it look like it died on rotation, but not sure. Did the block insert and then function cancel? If so it probably means your attributes are Preset and are not prompting for a value causing the function to error out.

 

One thing to try is set ATTREQ to 0 then run your command without the attribute data. If that works then maybe explore some more.

Try this after setting ATTREQ 0

(command "insert" "TRT-EXT" p6 (* 1 lts) "" "")

 

You may also consider uploading your block here as well.

 

 

0 Likes
Message 5 of 12

Anonymous
Not applicable

I need to fill some attributes in may lisp program. You line only inserts block and stops: (command "insert" "TRT-EXT" p6 (* 1 lts) "" "")

Before CAD 2014 my line worked fine. No not:

(command "insert" "TRT-EXT" p6 (* 1 lts) "" "" "UR" "" "" "" "")

How I can fill with lisp program some atributes in new CAD platforms?

 

0 Likes
Message 6 of 12

Anonymous
Not applicable

Then you insert block, after rotation, instead of command line program opens Edit Attributes window. In CAD 2013 you could continue infill information on command line.

My lisp line looks:

(command "insert" "TRT-EXT" p6 (* 1 lts) "" "" "UR" "" "" "" "")

where last "" was inputs of attributes.

0 Likes
Message 7 of 12

SeeMSixty7
Advisor
Advisor

If it insert the block and stops that's a good sign. Up load your block and let me test it or have some of the other people on here test it. It should work. Did you look at the properties of your attributes? Are they Preset?

0 Likes
Message 8 of 12

Anonymous
Not applicable

I uploaded TRT-EXT block and lisp program UNIT-UR.

 

0 Likes
Message 9 of 12

ВeekeeCZ
Consultant
Consultant
Accepted solution
Have you tried ATTDIA?
Message 10 of 12

alanjt_
Collaborator
Collaborator

Try replacing "insert" with "_.-insert"

0 Likes
Message 11 of 12

Anonymous
Not applicable

Yes, after changed ATTDIA to 0 my lisp started to work again.

Thank you

Message 12 of 12

SeeMSixty7
Advisor
Advisor
Accepted solution

As @ВeekeeCZ pointed out, this is typically one of the first things that should be done when using command to insert blocks. Also checke the value of ATTREQ.

 

I updated your lisp routine to check the existing values and then reset them back, when your command is done.

 

Good luck,

(defun c:UNIT-UR (/ lts p1 p2 p3 p4 P5 P6 attdia attreq)
  (setq lts (getvar "ltscale")
  	    attdia (getvar "ATTDIA")
  	    attreq (getvar "ATTREQ")
  )
  (setvar "plinewid" (* 0.02 lts))
  (command "layer" "m" "C_UNIT-DETERIORATED" "c" "245" "" "")
  (setq p1 (getpoint "\nSelect first corner point: "))
  (setq p3 (getcorner p1 "\nSelect opposite corner of rectangle: "))
  (setq p2 (list (nth 0 p3) (nth 1 p1)))
  (setq p4 (list (nth 0 p1) (nth 1 p3)))
  (command "pline" p1 p2 p3 p4 "c")
  (command "-bhatch" "p" "ansi31" (* 0.4 lts) "0" "s" "l" "" "")
  (command "layer" "m" "TREATMENT" "c" "4" "" "")
  (command "ortho" "on")
  (setq p1 (getpoint "\nSelect first point: "))
  (setq p5 (getPOINT p1 "\nSelect NEXT POINT: "))
  (setq p6 (getPOINT p5 "\nSelect FIRST POINT: "))

 (command "_QLEADER" p1 P5 P6 CANCEL) 
 (setvar "ATTDIA" 0)
 (setvar "ATTREQ" 1)
 (command "insert" "TRT-EXT" p6 (* 1 lts) "" "" "UR" "" "" "" "")
 (setvar "ATTDIA" attdia)
 (setvar "ATTREQ" attreq)
 (princ)
)
0 Likes