Author Topic: NCOPY entire layer  (Read 14804 times)

0 Members and 1 Guest are viewing this topic.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
NCOPY entire layer
« on: August 01, 2008, 12:04:19 PM »
Anyone got a way of copying all nested objects on a user-defined/selected layer?  That they'd like to share?
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

T.Willey

  • Needs a day job
  • Posts: 5251
Re: NCOPY entire layer
« Reply #1 on: August 01, 2008, 12:29:44 PM »
Here is one I wrote with the help of gile, and then the copy xref layer ( CopyNestedLayer ) was an idea I got from Joe Burke.  Here are some subs that are needed for the file.  Let me know if I missed anything.

Code: [Select]
(defun GetCurrentSpace (Doc / BlkCol SpaceList CurSpace ActSpace temp1)
; Returns the "block object" for the active space
; Thanks to Jeff Mishler

(if (= (getvar "cvport") 1)
(vla-get-PaperSpace Doc)
(vla-get-ModelSpace Doc)
)
)
Code: [Select]
(defun SingleSelect (Listof Message Toggle / DiaLoad tmpStr tmpTog tmpList)

(setq DiaLoad (load_dialog "MyDialogs.dcl"))
(if (new_dialog "SingleSelect" DiaLOad)
(progn
(start_list "listbox" 3)
(mapcar 'add_list Listof)
(end_list)
(if Message
(set_tile "text1" Message)
)
(if (not Toggle)
(mode_tile "toggle1" 1)
)
(action_tile "listbox"
"(if (= $reason 4)
(progn
(setq tmpStr (get_tile \"listbox\"))
(if Toggle
(setq tmpTog (get_tile \"toggle1\"))
)
(done_dialog 1)
)
)"
)     
(action_tile "accept"
"(progn
(setq tmpStr (get_tile \"listbox\"))
(if Toggle
(setq tmpTog (get_tile \"toggle1\"))
)
(done_dialog 1)
)"
)
(action_tile "cancel" "(done_dialog 0)")
(if (= (start_dialog) 1)
(progn
(setq tmpList (read (strcat "(" tmpStr ")")))
(if (= tmpTog "1")
(cons T tmpList)
tmpList
)
)
)
)
)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: NCOPY entire layer
« Reply #2 on: August 01, 2008, 12:40:47 PM »
Thanks.

Didn't forget anything.  It doesn't like undo'ing that though.  Just got a fatal error regarding the acxrefservice....arx.   :|
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

T.Willey

  • Needs a day job
  • Posts: 5251
Re: NCOPY entire layer
« Reply #3 on: August 01, 2008, 01:04:21 PM »
Thanks.

Didn't forget anything.  It doesn't like undo'ing that though.  Just got a fatal error regarding the acxrefservice....arx.   :|
I don't know that one.  I don't see it in my arx list, and I was able to undo with no problem.  Sorry to hear that.

You're welcome.

Quote
Command: copynestedlayer

Initializing...
 Select object of nested layer to copy:
    Copied layer: E-GRIDLINE, Object count: 45
 Select object of nested layer to copy:


Command:
Command: u GROUP
Command: u LAYOUT_CONTROL Regenerating layout.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

xshrimp

  • Mosquito
  • Posts: 14
Re: NCOPY entire layer
« Reply #4 on: August 04, 2008, 08:27:14 AM »
 :-
Code: [Select]
;;;Dhttp://www.xdcad.net/forum/showthread.php?s=&postid=2278035#post2278035
(defun c:bcopy (/ e el)
  (while (and
   (setq e (nentselp "\n选择块内实体: "))
   (= (length e) 4)
)
    (setq el (entget (car e)))
    (entmake el)
    (vla-transformby (vlax-ename->vla-object (entlast))
     (vlax-tmatrix (caddr e))
    )   
  )
  (princ)
)
abc

Joe Burke

  • Guest
Re: NCOPY entire layer
« Reply #5 on: August 04, 2008, 09:44:08 AM »
Thanks.

Didn't forget anything.  It doesn't like undo'ing that though.  Just got a fatal error regarding the acxrefservice....arx.   :|

Matt,

When undo causes a fatal error immediatly after running a lisp routine, it usually means a StartUndoMark was set without a corresponding EndUndoMark called.

This has been a long standing issue. Code must ensure this does not happen, typically by calling EndUndoMark in an error handler.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: NCOPY entire layer
« Reply #6 on: August 04, 2008, 11:48:20 AM »
Thanks.

Didn't forget anything.  It doesn't like undo'ing that though.  Just got a fatal error regarding the acxrefservice....arx.   :|

Matt,

When undo causes a fatal error immediatly after running a lisp routine, it usually means a StartUndoMark was set without a corresponding EndUndoMark called.

This has been a long standing issue. Code must ensure this does not happen, typically by calling EndUndoMark in an error handler.

Matt,

  If this is the case, then my is the opposite, but may cause the same error.  I call EndUndoMark twice, and that might cause the error, so to fix that comment out the call in the main function, as it will be called when the error routine is called without an argument ( when call with a nil argument ).

  Thanks for the heads up Joe.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Joe Burke

  • Guest
Re: NCOPY entire layer
« Reply #7 on: August 05, 2008, 08:01:05 AM »
Quote
Matt,

  If this is the case, then my is the opposite, but may cause the same error.  I call  EndUndoMark  twice, and that might cause the error, so to fix that comment out the call in the main function, as it will be called when the error routine is called without an argument ( when call with a nil argument ).

  Thanks for the heads up Joe.

Hi Tim,

AFAIK two EndUndoMarks in succession at the end of a routine do not cause a crash problem when the routine is undone. I have a few routines which call StartUndoMark and EndUndoMark in a loop so each loop can be undone. Those routines also call EndUndoMark in the error handler which is called at the end with (*error* nil).

BTW, the crash problem with an "open" StartUndoMark may only occur when undo is called multiple times immediately after the routine ends. That's my recollection anyway. One undo probably won't crash. Another one will probably cause a fatal error. I haven't checked this in recent versions.

dannypd

  • Guest
Re: NCOPY entire layer
« Reply #8 on: May 06, 2009, 11:53:28 AM »
it gives an error while selecting nested object:
 Error-->: no function definition: GETCURRENTSPACE

T.Willey

  • Needs a day job
  • Posts: 5251
Re: NCOPY entire layer
« Reply #9 on: May 06, 2009, 12:26:18 PM »
it gives an error while selecting nested object:
 Error-->: no function definition: GETCURRENTSPACE

That sub, and the other one you would need, is in the post where the code is at ( the second post in this thread ).
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

sifntsifnt

  • Guest
Re: NCOPY entire layer
« Reply #10 on: March 02, 2010, 06:39:33 PM »
hi there. This lisp is what ive been looking for. Looks great.. but unfortunately i do not understand how the subs and the .dcl are meant to work. Where do i places them and how do i get the subs to work?

sorry to ask such a beginner question. Also is there a condensed version of this LISP around now days? or a simply way of doing this?

I am running Autocad full 2010. Cheers pete
« Last Edit: March 02, 2010, 06:51:22 PM by sifntsifnt »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: NCOPY entire layer
« Reply #11 on: March 02, 2010, 06:54:52 PM »
Welcome to the swamp.

Take the lisp file ( *.lsp ).  Copy the two codes, within the second post in this thread, into the lisp file.  Save that.  Take the dialog file ( *.dcl ), and place that within a folder that is within the support paths.  Then you load the lisp.  ' Appload ' or ' ap ' should show the dialog box to load the lisp file.  Then select the *.lsp file.  Once it's loaded you can use the commands that it defines, which is called out in the second post also.

If that doesn't help, tell us what you have tried, and what error messages are shown.

I don't think there is another version of the code ( unless Joe has posted his, but that would most likely be the same complexity ), and I have not rewritten it in lisp.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

sifntsifnt

  • Guest
Re: NCOPY entire layer
« Reply #12 on: March 03, 2010, 01:03:41 AM »
thanks for the reply. Your a gentleman. unfortunately i know very little.

I added the subs into the lisp... at the top. put those break thingies between (hehehe... sorry at my little knowledge.. but try to explain)

i added the .DCL file to a folder in autocad support folder... and then added that to the autocad support list.

When i run 'copynested' or copynestedlayer' i get the same error.

Command: copynestedlayer
; error: An error has occurred inside the *error* functionno function
definition: VLA-ENDUNDOMARK

which would show to me its firing up the lisp... but an error is occuring inside?

    (defun *error* (msg)
       
        (vla-EndUndoMark ActDoc)
        (if dbxApp (vl-catch-all-apply 'vlax-release-object (list dbxApp)))
        (setq dbxApp nil)
        (prompt (strcat "\n Error-->: " msg))
    )

not sure what. No hassles its it too hard to trouble shot from a distance.
« Last Edit: March 03, 2010, 01:07:12 AM by sifntsifnt »

Joe Burke

  • Guest
Re: NCOPY entire layer
« Reply #13 on: March 03, 2010, 10:30:24 AM »
I suspect you need to revise the error handler with this added cond statement:

  (defun *error* (msg)
    (cond
      ((not msg))
      ((wcmatch (strcase msg) "*QUIT*,*CANCEL*"))
      (T (princ (strcat "\nError: " msg)))
    )


T.Willey

  • Needs a day job
  • Posts: 5251
Re: NCOPY entire layer
« Reply #14 on: March 03, 2010, 10:59:04 AM »
Are you using Lt with a Lisp enabler?  Or are you suing Briscad?  Or what version of Acad you using?

The error should not happen in the later versions of Acad, as it is saying that a built in function is not there.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.