Author Topic: DCL/LISP to insert block from list  (Read 3283 times)

0 Members and 1 Guest are viewing this topic.

dgorsman

  • Water Moccasin
  • Posts: 2422
Re: DCL/LISP to insert block from list
« Reply #30 on: June 28, 2020, 04:20:41 PM »
And with things the way they are, many are trimming 'non-essential activities' during their work day.  So less time spent here and elsewhere helping others.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

MP

  • Seagull
  • Posts: 17655
  • Have thousands of dwgs to process? Contact me.
Re: DCL/LISP to insert block from list
« Reply #31 on: June 28, 2020, 05:31:32 PM »
June-August typically vacation time for many as well..
Engineering Technologist Programmer Analyst CAD Specialist
Multi-Discipline Design Drafting Document Control Automation.
cadanalyst@gmail.com www.linkedin.com/in/cadanalyst

roy_043

  • Water Moccasin
  • Posts: 1783
  • BricsCAD 18
Re: DCL/LISP to insert block from list
« Reply #32 on: June 30, 2020, 03:43:40 AM »
drawing "D" cannot be found!

The issue is that you are passing a string "D" instead of a variable D.

Before going on with your work you should read up on variables and their scope. This is an often neglected topic in the AutoLisp world. Sadly this also applies to much of the educational material that is out there, including the examples in the official AutoCAD documentation.

Lee Mac has a nice explanation on his website:
http://www.lee-mac.com/localising.html

sln8458

  • Mosquito
  • Posts: 18
Re: DCL/LISP to insert block from list
« Reply #33 on: June 30, 2020, 07:11:11 AM »
Hi Roy,

Thanks for the info, though I had found that.


Code: [Select]
(defun
   INSERT_BLOCK2 ()
  (princ D) ; print the content of D variable to the command line.
  (command
"._-insert" D pause 1 1 0 ;INSERT BLOCK 2
   ) ;_ end of command

Here is the command history with the above implemented:

Command:
Command:
Rendering support loaded.
Raster image support loaded.
Command:
Command: fredsingle2LD-200MM-TRAY-RUN-3000
<Select insert point>/Reference: LD-200MM-TRAY-RUN-3000
Command: '_PMTHIST

I can see what variable D is, but this is still not getting to the "insert" command.



S

roy_043

  • Water Moccasin
  • Posts: 1783
  • BricsCAD 18
Re: DCL/LISP to insert block from list
« Reply #34 on: June 30, 2020, 09:48:49 AM »
Apart from the missing final closing parenthesis, and the quaint indentation, the code should work. Maybe the block has attributes? Or maybe you are calling this function when the dialog is still displayed?

sln8458

  • Mosquito
  • Posts: 18
Re: DCL/LISP to insert block from list
« Reply #35 on: June 30, 2020, 11:49:42 AM »
Hi Roy,

The closing parenthesis is there, just my hasty copying.

Code: [Select]
(defun
   SET_BLOCK ()
  (setq
    D  (nth 1 SIZE_DIMS)
  ) ;end setq
  (INSERT_BLOCK2) ;GOTO INSERT BLOCK2
 ) ;End SET_BLOCK
  ;-----------------------------------------------------------------------;
  ;-----------------------------------------------------------------------;
  ;-----------------------------------------------------------------------;
  ;-----------------------------------------------------------------------;
  ;-----------------------------------------------------------------------;
(defun
   INSERT_BLOCK1 ()
  (command
"._-insert" "RT" pause 1 1 0 ;INSERT BLOCK 1
   ) ;_ end of command
) ;end INSERT_BLOCK1
(defun
   INSERT_BLOCK2 ()
  (princ D) ; print the content of D variable to the command line.
  (command
        "._-insert" D pause 1 1 0 ;INSERT BLOCK2
   ) ;_ end of command
) ;end INSERT_BLOCK2

FYI I added a named block to insert which works, this block does have attributes and does not appear to cause any issues.

The (princ D) does display the block (dwg) name ie LD-200MM-TRAY-RUN-3000
which makes me think that the INSERT_BLOCK2 has initiated but for some reason the (command "._-insert" .......) is not?

But then I am thick!  :uglystupid2:

S

roy_043

  • Water Moccasin
  • Posts: 1783
  • BricsCAD 18
Re: DCL/LISP to insert block from list
« Reply #36 on: June 30, 2020, 03:40:05 PM »
Post the LD-200MM-TRAY-RUN-3000 file. Maybe there is a recursion issue?

sln8458

  • Mosquito
  • Posts: 18
Re: DCL/LISP to insert block from list
« Reply #37 on: July 01, 2020, 03:58:11 AM »
Hi Roy,

Do you want the 'dwg' file or the 'lsp' file?

S

roy_043

  • Water Moccasin
  • Posts: 1783
  • BricsCAD 18
Re: DCL/LISP to insert block from list
« Reply #38 on: July 02, 2020, 03:13:32 AM »
I meant the DWG, but you can post both files if you like.

sln8458

  • Mosquito
  • Posts: 18
Re: DCL/LISP to insert block from list
« Reply #39 on: July 02, 2020, 03:21:58 AM »
Thanks for the offer, but I have found the issue.

The issue was in the formatting of the txt file

I had:
("LD-75mm     Straight Run  3mtr" LD-75mm-tray-run-3000)

But I needed:
("LD-75mm     Straight Run  3mtr" "LD-75mm-tray-run-3000")

S