Jump to content

Recommended Posts

Posted

hello i have nanocad 11 and try to use my old autocad lisp files but they seem not work. what can i do?

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • jim78b

    13

  • BIGAL

    5

  • hanhphuc

    3

  • maratovich

    2

Top Posters In This Topic

Posted Images

Posted

When you say it does not work that's a bit broad statement, like Autocad Mac there is no VL so some lisps don't run. Need to test with simple lisp and work up to more complex, when Intellicad first came out had to do some minor recode on some lisps. Briscad Polygon works different to Autocad just a nuisance but solvable.

 

 

Posted

.Oh i don't know this i thought that lisp work at 100.i wanted buy nanocad but this thing make me some doubt about it...is there not possibilità to run sone lisp code ?

Posted

 

Try to debug manually, copy every line of code in command line princ the comment or check variable

 

example

(setq p (getpoint "\npick point"))

(setq dist (getdist "\nNow get dist"))

(princ "\nBegin polar ")

(setq b (polar p ang dist))

(princ "after polar what happen?")

(princ "etc...")

 

if error occurs, check & see where the comment stops

check variable !dist ,  !ang etc..

 

 

or just post your problem LISP file, perhaps others may help too

 

p/s: and & progn 

Posted (edited)

Ok i don't know lisp programming..is better i post my lisp files 

How can i know the Syntax of nanocad lisp ?

Edited by jim78b
Posted
(defun C:RTC (/ gru)
(setq gru (ssget))

(if gru
(progn
(command "_COPY" gru "" (list 0 0)(list 0 0))
(command "_ROTATE" "_P" "")
(princ "\nBase point e primo punto d'angolo: ")
(command pause "_R")
(command (getvar "LASTPOINT"))
(princ "\nSecondo punto d'angolo: ")
(command pause)
(princ "\nAngolo finale: ")
(command pause)
)
)

(princ)
)

HELLO I WRITE A LISP THAT DON'T work, if possible i want insert the number of copies i want when rotate thanks in advance

 

 

Posted
49 minutes ago, jim78b said:

(defun C:RTC (/ gru)
(setq gru (ssget))

(if gru
(progn
(command "_COPY" gru "" (list 0 0)(list 0 0))
(command "_ROTATE" "_P" "")
(princ "\nBase point e primo punto d'angolo: ")
(command pause "_R")
(command (getvar "LASTPOINT"))
(princ "\nSecondo punto d'angolo: ")
(command pause)
(princ "\nAngolo finale: ")
(command pause)
)
)

(princ)
)

HELLO I WRITE A LISP THAT DON'T work, if possible i want insert the number of copies i want when rotate thanks in advance

 

 

 

 

What is your version of NanoCAD?
I checked on Nanocad x64 plus 20.0 - your lisp works.

Posted

MY VERSION IS the last nanocad pro 11, the list don't permit me to set the second reference point

Posted

ok i resolve the lisp rtc now i have a lisp of leemac that rename a block but don't work

 

;;-----------------=={ Copy/Rename Block Reference }==------------------;;
;;                                                                      ;;
;;  This program allows a user to copy and/or rename a single block     ;;
;;  reference in the working drawing.                                   ;;
;;                                                                      ;;
;;  Many existing programs enable the user to rename the block          ;;
;;  definition for a given block reference, with the new name           ;;
;;  subsequently reflected across all references of the block           ;;
;;  definition in the drawing. However, this program will allow a       ;;
;;  single selected block reference to be renamed (or for the user to   ;;
;;  create a renamed copy of the selected block reference), by          ;;
;;  generating a duplicate renamed block definition for the selected    ;;
;;  block.                                                              ;;
;;                                                                      ;;
;;  The program may be called from the command-line using either 'CB'   ;;
;;  to create a renamed copy of a selected block reference, or 'RB' to  ;;
;;  simply rename the selected block reference.                         ;;
;;                                                                      ;;
;;  Following selection of a block reference, the user is prompted to   ;;
;;  specify a name for the selected/copied block reference; a default   ;;
;;  block name composed of the original block name concatenated with    ;;
;;  both an underscore and the minimum integer required for uniqueness  ;;
;;  within the block collection of the active drawing is offered.       ;;
;;                                                                      ;;
;;  The program will then proceed to duplicate the block definition     ;;
;;  using the new block name. To accomplish this without resulting in   ;;
;;  a duplicate key in the block collection of the active drawing, the  ;;
;;  program utilises an ObjectDBX interface to which the block          ;;
;;  definition of the selected block reference is deep-cloned, renamed, ;;
;;  and then deep-cloned back to the active drawing. This method also   ;;
;;  enables Dynamic Block definitions to be successfully copied         ;;
;;  & renamed.                                                          ;;
;;                                                                      ;;
;;  Finally, this program will perform successfully in all UCS/Views    ;;
;;  and is compatible with Anonymous Blocks, Dynamic Blocks & XRefs.    ;;
;;----------------------------------------------------------------------;;
;;  Author:  Lee Mac, Copyright © 2013  -  www.lee-mac.com              ;;
;;----------------------------------------------------------------------;;
;;  Version 1.5    -    05-07-2013                                      ;;
;;----------------------------------------------------------------------;;

(defun c:cb nil (LM:RenameBlockReference   t))
(defun c:rb nil (LM:RenameBlockReference nil))

(defun LM:RenameBlockReference ( cpy / *error* abc app dbc dbx def doc dxf new old prp src tmp vrs )

    (defun *error* ( msg )
        (if (and (= 'vla-object (type dbx)) (not (vlax-object-released-p dbx)))
            (vlax-release-object dbx)
        )
        (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
            (princ (strcat "\nError: " msg))
        )
        (princ)
    )
    
    (while
        (progn
            (setvar 'errno 0)
            (setq src (car (entsel (strcat "\nSelect block reference to " (if cpy "copy & " "") "rename: "))))
            (cond
                (   (= 7 (getvar 'errno))
                    (princ "\nMissed, try again.")
                )
                (   (= 'ename (type src))
                    (setq dxf (entget src))
                    (cond
                        (   (/= "INSERT" (cdr (assoc 0 dxf)))
                            (princ "\nPlease select a block reference.")
                        )
                        (   (= 4 (logand 4 (cdr (assoc 70 (tblsearch "layer" (cdr (assoc 8 dxf)))))))
                            (princ "\nSelected block is on a locked layer.")
                        )
                    )
                )
            )
        )
    )
    (if (= 'ename (type src))
        (progn
            (setq app (vlax-get-acad-object)
                  doc (vla-get-activedocument app)
                  src (vlax-ename->vla-object src)
                  old (vlax-get-property src (if (vlax-property-available-p src 'effectivename) 'effectivename 'name))
                  tmp 0
            )
            (while (tblsearch "block" (setq def (strcat (vl-string-left-trim "*" old) "_" (itoa (setq tmp (1+ tmp)))))))
            (while
                (and (/= "" (setq new (getstring t (strcat "\nSpecify new block name <" def ">: "))))
                    (or (not (snvalid new))
                        (tblsearch "block" new)
                    )
                )
                (princ "\nBlock name invalid or already exists.")
            )
            (if (= "" new)
                (setq new def)
            )
            (setq dbx
                (vl-catch-all-apply 'vla-getinterfaceobject
                    (list app
                        (if (< (setq vrs (atoi (getvar 'acadver))) 16)
                            "objectdbx.axdbdocument"
                            (strcat "objectdbx.axdbdocument." (itoa vrs))
                        )
                    )
                )
            )
            (if (or (null dbx) (vl-catch-all-error-p dbx))
                (princ "\nUnable to interface with ObjectDBX.")
                (progn
                    (setq abc (vla-get-blocks doc)
                          dbc (vla-get-blocks dbx)
                    )
                    (vlax-invoke doc 'copyobjects (list (vla-item abc old)) dbc)
                    (if (wcmatch old "`**")
                        (vla-put-name (vla-item dbc (1- (vla-get-count dbc))) new)
                        (vla-put-name (vla-item dbc old) new)
                    )
                    (vlax-invoke dbx 'copyobjects (list (vla-item dbc new)) abc)
                    (vlax-release-object dbx)
                    (if cpy (setq src (vla-copy src)))
                    (if
                        (and
                            (vlax-property-available-p src 'isdynamicblock)
                            (= :vlax-true (vla-get-isdynamicblock src))
                        )
                        (progn
                            (setq prp (mapcar 'vla-get-value (vlax-invoke src 'getdynamicblockproperties)))
                            (vla-put-name src new)
                            (mapcar
                               '(lambda ( a b )
                                    (if (/= "ORIGIN" (strcase (vla-get-propertyname a)))
                                        (vla-put-value a b)
                                    )
                                )
                                (vlax-invoke src 'getdynamicblockproperties) prp
                            )
                        )
                        (vla-put-name src new)
                    )
                    (if (= :vlax-true (vla-get-isxref (setq def (vla-item (vla-get-blocks doc) new))))
                        (vla-reload def)
                    )
                    (if cpy (sssetfirst nil (ssadd (vlax-vla-object->ename src))))
                )
            )
        )
    )
    (princ)
)

;;----------------------------------------------------------------------;;

(vl-load-com)
(princ
    (strcat
        "\n:: CopyRenameBlock.lsp | Version 1.5 | \\U+00A9 Lee Mac "
        (menucmd "m=$(edtime,$(getvar,date),YYYY)")
        " www.lee-mac.com ::"
        "\n:: Available Commands:"
        "\n::    \"CB\"  -  Copy & Rename Block Reference."
        "\n::    \"RB\"  -  Rename Block Reference."
    )
)
(princ)

;;----------------------------------------------------------------------;;
;;                             End of File                              ;;
;;----------------------------------------------------------------------;;

 

Posted

Not sure if Nanocad supports Visual Lisp the VL- so a simple test.

 

Type this (vl-load-com)
T should appear if error message then no VL
then type (setq obj (vlax-ename->vla-object (car (entsel "Pick object "))))
Pick object #<VLA-OBJECT IAcadLine 000000002D06C1F0> I picked a line 

 

Posted

(vl-load-com) to command line

if T

then 

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

Posted

give me:

 

_>: (setq obj (vlax-ename->vla-object (car (entsel "Pick object "))))
Pick object
error: invalid argument type: LENTITYP: nil

Posted
18 hours ago, jim78b said:

give me:

 

_>: (setq obj (vlax-ename->vla-object (car (entsel "Pick object "))))
Pick object
error: invalid argument type: LENTITYP: nil

 

seems you just picked nothing?

 

 

Posted

But don't me Permit to select anything

Posted
2 hours ago, jim78b said:

But don't me Permit to select anything

 

Maybe another version will help you.
Here is the link to version 20.0
nanoCAD Plus 20.0 x64

I don’t know if there are different languages or not. But I think that it will not be difficult to understand. The teams are the same as in AutoCAD.

 

 

 

 

 

 

 

 

ver.png

Posted (edited)

SORRY BUT I WENT TO THE ENGLISH SITE AND DOWNLOAD THE TRIAL ...IS 11!

 

https://nanocad.com/products/plus/

 

 

IN NANOCAD i call the console with lsp then C

 

copy :

 

(vl-load-com) and press enter

nothing happen

 

then paste:

 

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?

Edited by jim78b
Posted

(vl-load-com)

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

Posted

Sorry not understand now what should have i do ?

Posted (edited)

When I type (vl-load-com) on the command line it displays "T" meaning it has loaded.  If it reports a ERROR then the code you originally posted will not work as it has Visual lisp functions and does not work with Nanocad

 

You need to post the error messages not just say it does not work.

Edited by BIGAL

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...