SCRIPT or LISP for overlaying

SCRIPT or LISP for overlaying

Akshay.Sharma2
Explorer Explorer
878 Views
10 Replies
Message 1 of 11

SCRIPT or LISP for overlaying

Akshay.Sharma2
Explorer
Explorer

Hello there,
To use with Lee's Script Writer, I'm working on developing a lisp. I can't seem to get it to function.
I want to do the following:

  1. open the *file*
  2. move to model space
  3. overlay an dwg at a coordinate
  4. reconcile layers
  5. save
  6. close

1,2,5,6 are done in Script Writer and are working file as i have tested them.

This is what i came up with:

(defun c:lol ()
(Command "TILEMODE" "1" "FILEDIA" "0" "-ATTACH" "R:\Legend templates_JG.dwg" "O" "100,100" "1" "1" "0" "-LAYER" "E" "*" " ")

 

The attach command fails to use the specified location, and the reconcile layer command hangs at the end and does not exit. Please assist this autolisp novice.

Thank you very much.

0 Likes
Accepted solutions (3)
879 Views
10 Replies
Replies (10)
Message 2 of 11

paullimapa
Mentor
Mentor
Accepted solution

instead of "R:\Legend templates_JG.dwg"

try: "R:\\Legend templates_JG.dwg"

or:

"R:/Legend templates_JG.dwg"

Also if there are no layers to reconcile in the drawing then this part of the code will fail:

"-LAYER" "E" "*" " "


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 11

paullimapa
Mentor
Mentor

found this nice code to check if there are any unreconciled layers in current drawing.

if there are, will return a list. if there are none will return nil:

How to list unreconciled layers. (theswamp.org)

; unreconlayers function returns list of layers that are unreconciled or nil if none 
; https://www.theswamp.org/index.php?topic=50448.0
(defun unreconlayers ( / def dic lay lst )
    (while (setq def (tblnext "layer" (not def)))
        (setq lay (cdr (assoc 2 def))
              dic (cdr (assoc 360 (entget (tblobjname "layer" lay))))
        )
        (or (and  dic (dictsearch dic "adsk_xrec_layer_reconciled"))
            (setq lst (cons lay lst))
        )
    )
    (reverse lst)
)

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 11

Akshay.Sharma2
Explorer
Explorer

R:/Legend templates_JG.dwg this one is working.

0 Likes
Message 5 of 11

paullimapa
Mentor
Mentor

Yes when using lisp replace \ with / or \\ because lisp uses \ as escape code


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 11

Akshay.Sharma2
Explorer
Explorer
Thank you for the insight.
Now, I am trying to figure out a way to utilize the "unreconlayers" function so that if it finds layers to reconcile , it does reconciliation else close it.
0 Likes
Message 7 of 11

paullimapa
Mentor
Mentor
Accepted solution

easy:

(If (unreconlayers)

(progn

do this when there are unreconciled layers

) ; progn 

(progn

else do this when there are none

) ; else

) ; if


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 11

Akshay.Sharma2
Explorer
Explorer

I tried this :

(defun C:fixreconcile ( / def dic lay lst )
    (If (unreconlayers)
(progn (command "-LAYER" "E" "*" " ")
) ; progn 
(progn(princ "\nNo layers to reconcile.")
) ; else 
) ; if
)

It is working but still does not closes and shows:

Command: FIXRECONCILE -LAYER
Current layer:  "0"
Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]: E
Enter name list of layer(s) to turn reconcile or <select objects> or [?]: * Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile/Xref]:
Invalid option keyword.
; error: Function cancelled
0 Likes
Message 9 of 11

paullimapa
Mentor
Mentor
Accepted solution

why add a space between the quotes?

Don’t do this:

(command "-LAYER" "E" "*" " ")

Do this:

(command "-LAYER" "E" "*" "")

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 10 of 11

Akshay.Sharma2
Explorer
Explorer
Thank you for guiding me out
0 Likes
Message 11 of 11

paullimapa
Mentor
Mentor

You are welcome...cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes