Jump to content

Recommended Posts

Posted
;;  BN0.lsp [command name the same]
;;    = change all Block Entities [other than on Layer Defpoints] in selected Blocks'
;;    definitions, including in any Nested Blocks, to Layer 0 with Color & Linetype
;;    overrides from entity's source layer properties [if not otherwise overridden]
;;  Kent Cooper, last edited 4 November 2014

(vl-load-com)
(defun C:BN0 (/ *error* nametolist doc blkss inc blokobj blkname blknames ent edata ldata)

 (defun *error* (errmsg)
   (if (not (wcmatch errmsg "Function cancelled,quit / exit abort,console break"))
     (princ (strcat "\nError: " errmsg))
   ); if
   (vla-endundomark doc)
   (princ)
 ); defun - *error*

 (defun nametolist (blk / blkobj blkname); get Block name and put it into list of names
   (if (= (logand (cdr (assoc 70 (entget blk))) 4) 0) ; not an Xref
     (progn
       (setq
         blkobj (vlax-ename->vla-object blk)
         blkname
           (vlax-get-property blkobj
             (if (vlax-property-available-p blkobj 'EffectiveName) 'EffectiveName 'Name)
               ; to work with older versions that don't have dynamic Blocks
           ); ...get-property & blkname
       ); setq
       (if
         (not (member blkname blknames)); name not already in list
         (setq blknames (append blknames (list blkname))); then -- add to end of list
       ); if
     ); progn
   ); if
 ); defun -- nametolist

 (setq doc (vla-get-activedocument (vlax-get-acad-object)))
 (vla-startundomark doc); = Undo Begin

 (if (setq blkss (ssget '((0 . "INSERT")))); User selection of any number of Blocks/Minserts/Xrefs
   (progn; then
     (repeat (setq inc (sslength blkss)); list of Block names from top-level selection
       (nametolist (ssname blkss (setq inc (1- inc))))
     ); repeat
     (while (setq blk (car blknames)); as long as there's another Block name in list
       ;; [this way instead of via (repeat) or (foreach), so it can add Nested Blocks' names to list]
       (setq ent (tblobjname "block" blk)); Block definition as entity
       (if (= (logand (cdr (assoc 70 (entget ent))) 4) 0) ; not an Xref
         (while (setq ent (entnext ent)); then -- proceed through sub-entities in definition
           (setq edata (entget ent))
           (if (member '(0 . "INSERT") edata) (nametolist ent)); if nested Block, add name to end of list
           (if (not (member '(8 . "Defpoints") edata)); process all entities NOT on Layer Defpoints
             (progn ; then
               (setq ldata (entget (tblobjname "layer" (cdr (assoc 8 edata))))); entity's Layer's properties
               (if
                 (or ; [no Color override]
                   (not (assoc 62 edata)); Bylayer
                   (member '(62 . 0) edata); Byblock
                 ); or
                 (setq edata (append edata (list (assoc 62 ldata)))); then -- assign Layer's color
               ); if
               (if
                 (and
                   (or ; [no Linetype override]
                     (not (assoc 6 edata)); Bylayer
                     (member '(6 . "ByBlock") edata)
                   ); or
                   (not (member '(6 . "Continuous") ldata))
                     ; don't override ByLayer/ByBlock with Layer's linetype if Continuous
                 ); and
                 (setq edata (append edata (list (assoc 6 ldata)))); then -- assign Layer's linetype
               ); if
               (setq edata (subst '(8 . "0") (assoc 8 edata) edata)); to Layer 0
               (entmod edata)
             ); progn -- then
           ); if -- not on Defpoints
         ); while -- sub-entities
       ); if
       (setq blknames (cdr blknames)); take first Block name off list
     ); while
     (command "_.regen")
   ); progn
   (prompt "\nNo Block(s) selected."); else
 ); if [user selection]
 (vla-endundomark doc); = Undo End
 (princ)
); defun

(prompt "\nType BENL0CL to change all selected Blocks' Entities to Layer 0 retaining their Layers' color/linetype.")

hello i have this lisp that in nanocad pro don't work.... any suggestion?

 

give me:

 

COM
NOT_IMPLEMENTED
CDocumentObj::StartUndoMark

Posted (edited)

I asked elsewhere does Nanocad support Vlisp ? I did not get your answer in other post !

 

Maybe this also (vlax-product-key) it should return something about Nanocad

 

For Bricscad = "Software\\Bricsys\\BricsCAD\\V19x64\\en_US"

 

If you don't understand basic commands being typed on the command line we have a real problem.

Edited by BIGAL
Posted (edited)

Yes i reply ...and did the test in command line .

I paste your code and then ask me to select something. 

 

 

if T

then 

(setq obj (vlax-ename->vla-object (car (entsel "Pick object "))))

 

and press enter

 

now ASK ME TO PICK AN OBJECT SO IT WORKS. AND now what shall i do?

 

 

Have patience sorry ...

 

 

Edited by jim78b
Posted

If it does not work you should see error message,  copy and paste what appears on your screen.

Posted

Try replacing (2x):

(vla-endundomark doc)

with:

(command "_.undo" "_end")

 

And replacing (1x):

(vla-startundomark doc)

with:

(command "_.undo" "_group")

Posted

2020.05.01 08:47:37:657
COM
NOT_IMPLEMENTED
CDocumentObj::StartUndoMark

Posted

sorry don't working, open the group window

Posted

I hope you realize that opting for NanoCAD may not be a good idea if you rely on Lisp routines for your workflow. Both the Lisp API and the implementation of the commands are not AC compatible. Maybe you should look at BricsCAD instead?

Posted

Thanks a lot for all ...yes bit they make a lot of advertising about nanocad ...and pro cost about 300euro

Posted
47 minutes ago, Roy_043 said:

I hope you realize that opting for NanoCAD may not be a good idea if you rely on Lisp routines for your workflow. Both the Lisp API and the implementation of the commands are not AC compatible. Maybe you should look at BricsCAD instead?

It looks like: I'm trying 2008 AutoCAD and it doesn't work there.

  • Like 1
Posted
1 hour ago, Roy_043 said:

@maratovich

For a programmer that is a poor error report.

 

Because (I wrote here earlier):
The current version of nanoCAD = 20, the author of the topic uses the version of nanoCAD = 6.
Naturally, some commands cannot work in older versions.

Posted (edited)

I was just offered a beta version of the next Nanocad Plus 20 but I already have Bricscad and Autocad so refrained from loading.

 

Maybe all missed the obvious.

 

(prompt "\nType BENL0CL to change all selected Blocks' Entities to Layer 0 retaining their Layers' color/linetype.")

 

BENL0CL does not exist BN0 does

 

Did not seem to do anything ?

Edited by BIGAL
Posted
8 hours ago, BIGAL said:

Maybe all missed the obvious...

Not me: I have tested the c:BN0 function.

Posted

Thanks for tried...😊don't waste time .

Posted
9 hours ago, BIGAL said:

Still doing nothing Bricscad and Autocad.

Read the code and analyze the block before and after. It certainly works on BricsCAD.

Posted

Thanks bigal for spend time ...so in nanocad don't work i presume.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...