Author Topic: Return and run lisp  (Read 1795 times)

0 Members and 1 Guest are viewing this topic.

Jeroen

  • Newt
  • Posts: 21
  • BricsCAD & AutoLisp
Return and run lisp
« on: March 24, 2015, 11:39:06 AM »
Is it possible to create a lisp:
Create a new drawing from an entity in the main-drawing. Next the new drawing is opened and edited. To finish this, the new drawing is closed and you return in the main drawing. The new drawing is inserted in the main-drawing.

My setup so far: I run a lisp, that makes a wblock of the entity. Using vl-bb-set I create a 'trigger'. Next the new drawing, created with wblock, is opened and is edited by the lisp started from acaddoc.lsp and vl-bb-ref...

Now, when I return to the main-drawing I want to automatically insert the new drawing, but is that possible? With Lisp? Or do I need to do some other programming???

Can some-one help me or point me in the right direction....? Please?!

Jeroen
Jeroen

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Return and run lisp
« Reply #1 on: March 24, 2015, 12:24:05 PM »
You can use a reactor to respond to a 'document became current' event.
Something like this:
Code - Auto/Visual Lisp: [Select]
  1. (if (not *mainDwgDocmanagerReactor*)
  2.   (setq *mainDwgDocmanagerReactor*
  3.       nil ; No data.
  4.       '((:vlr-documentbecamecurrent . YourCallBackFunction))
  5.     )
  6.   )
  7. )
  8.  
  9. (defun YourCallBackFunction (obj lst)
  10.   (if (= (vl-bb-ref 'YourTrigger) 1)
  11.   )
  12.   (vl-bb-set 'YourTrigger 0)
  13.   (if *mainDwgDocmanagerReactor*
  14.     (progn
  15.       (vlr-remove *mainDwgDocmanagerReactor*)
  16.       (setq *mainDwgDocmanagerReactor* nil)
  17.     )
  18.   )
  19. )
  20.  
  21. (defun YourPostProcess ()
  22.   (print "PostProcess")
  23.   (princ)
  24. )

An alternative would be do use the ObjectDBX approach for the entire process you have described.

Note that you can also programmatically create a new block defintion in the main drawing without creating a wblock.
« Last Edit: March 24, 2015, 12:40:26 PM by roy_043 »

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Return and run lisp
« Reply #2 on: March 24, 2015, 01:44:31 PM »
Note that you can also programmatically create a new block defintion in the main drawing without creating a wblock.

^^ This.

I'm not sure what operations you are performing on the new drawing via your acaddoc.lsp, but I should imagine they could be performed directly on a new block definition in the active drawing, saving a lot of trouble.

Lee

Jeroen

  • Newt
  • Posts: 21
  • BricsCAD & AutoLisp
Re: Return and run lisp
« Reply #3 on: March 27, 2015, 08:03:12 AM »
The operations are:
create a 3DSOLID from a closed Polyline, add text, add dimensions, add attributes, create a new layout, fill in the drawing properties...
Jeroen