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

0 Members and 2 Guests are viewing this topic.

dgorsman

  • Water Moccasin
  • Posts: 2437
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: 17750
  • 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 • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

roy_043

  • Water Moccasin
  • Posts: 1895
  • 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

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
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
There is no such  thing as a 'silly question' to those who do not know!

roy_043

  • Water Moccasin
  • Posts: 1895
  • 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

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
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
There is no such  thing as a 'silly question' to those who do not know!

roy_043

  • Water Moccasin
  • Posts: 1895
  • 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

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
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
There is no such  thing as a 'silly question' to those who do not know!

roy_043

  • Water Moccasin
  • Posts: 1895
  • 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

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
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
There is no such  thing as a 'silly question' to those who do not know!

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: DCL/LISP to insert block from list
« Reply #40 on: July 15, 2020, 05:15:18 AM »
Just a final update on this project.

I managed to get it all working and have now added a 'preview' image.



Steve
There is no such  thing as a 'silly question' to those who do not know!

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: DCL/LISP to insert block from list
« Reply #41 on: July 15, 2020, 10:37:44 PM »
Looks very impressive.
A man who never made a mistake never made anything

sln8458

  • Newt
  • Posts: 91
  • CMS Intellicad 9.0/10.0
Re: DCL/LISP to insert block from list
« Reply #42 on: July 19, 2020, 05:44:13 AM »
Thank you BIGAL.

I'm pleased with the results, although I am still 'polishing'
I managed to achieve having all of the drawing numbers/names and the slides in the text file:
("LD-200mm RH Reducer" "LD-200mm-tray-Reducer-3000" "ldct5-r.sld")
where
"LD-200mm RH Reducer" is the text displayed in the list box
"LD-200mm-tray-Reducer-3000" is the drawing number/name
"ldct5-r.sld" is the slide displayed in the 'preview' image

And whilst this is probably food & drink to most of the posters here, it was more difficult for me.
This means that I can add new blocks to the lists without having to modify the lsp file. I still do not have the full set of blocks.
Or change the slides to individual rather than 'generic' ones.

The next project will include radio buttons and possibly 'concatenated' drawing numbers, and slides with generic dimension (ie 'A'  'B'   'C'...) and then a display of the actual dimensions, a bit like a catalogue. Again I hope to include the dimensions in the txt file so they will be n3, n4, n5........

.
There is no such  thing as a 'silly question' to those who do not know!

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: DCL/LISP to insert block from list
« Reply #43 on: July 19, 2020, 07:50:15 PM »
You can have sub dcl in a dcl so you dont need to close the parent dcl use this for entering sizes etc. If you need help let me know.

Also making slides can be scripted so open dwg mslide save close, I suggest Zoom E then 0.8XP it just zooms out a little bit, again I do it old fashioned DOS/CMD and Word very fast when you know what your doing.

The attached is a library getvals can have as many a syou like subject to screen size this version has image option. Look at screenshot.

« Last Edit: July 19, 2020, 08:11:24 PM by BIGAL »
A man who never made a mistake never made anything