compare managers code with a drafters code

Discussion in 'AutoCAD' started by no.name, Jun 16, 2004.

  1. no.name

    no.name Guest

    i passed a function thats opens a picked xref, to the cad manager.

    i know there both not perfect, but lets compare them anyway.

    i was informed that my lisp does too much checking, autocad takes care of
    all the errors & users don't need all that chaecking.

    managers code is derived from the code i gave him.

    which one do you think does a better job ?

    help support a lonely old drafter.

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    managers lisp

    (defun PickXrefOpen (/ olderr sel sdat)
    (errorsetup)
    (if
    (and
    (setq sel (entsel "\nSelect Xref: "))
    (eq "INSERT" (dxf 0 (setq sdat (entget (car sel)))))
    (not (null (pxo:xrefcheck (dxf 2 sdat)))))
    (progn
    (setq fnam (getfilepath (car sel)))
    (pxo:eek:pen fnam))
    (princ "\nNope."))
    (errorrestore)
    )

    (defun pxo:eek:pen (fil)
    (COMMAND
    "vbastmt"
    (STRCAT
    "AcadApplication.Documents.Open "
    (CHR 34)
    fil
    (CHR 34)
    )
    )
    )

    (DEFUN pxo:xrefcheck (bnam)
    (OR
    (=
    (VLA-GET-ISXREF
    (VLA-ITEM
    (VLA-GET-BLOCKS
    (VLA-GET-ACTIVEDOCUMENT
    (VLAX-GET-ACAD-OBJECT)))
    bnam
    )
    )
    :VLAX-TRUE
    )
    )
    )

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    my lisp below

    ;;;Open named drawing file (no error trapping is done!)
    ;| From newsgroup, it rocks |;
    (DEFUN pxto:eek:pendwg (opendwg:fullname)
    (SETVAR "cmdecho" 0)
    (PRINC "\n")
    (COMMAND "vbastmt"
    (STRCAT "AcadApplication.Documents.Open " (CHR 34)
    opendwg:fullname (CHR 34))
    ) ;_ end of COMMAND
    (SETVAR "cmdecho" 1)
    (PRINC (STRCAT "\n " pxto:xrpathname " was opened."))
    (PRINC)
    ) ;_ end of DEFUN

    ;;;

    ;|From newsgroup, it rocks |;
    (DEFUN pxto:isxref (isxref:bname)
    (OR
    (= (VLA-GET-ISXREF
    (VLA-ITEM (VLA-GET-BLOCKS (VLA-GET-ACTIVEDOCUMENT
    (VLAX-GET-ACAD-OBJECT))) ;_ end of VLA-GET-BLOCKS
    isxref:bname
    ) ;_ end of VLA-ITEM
    ) ;_ end of VLA-GET-ISXREF
    :VLAX-TRUE
    ) ;_ end of =
    ) ;_ end of OR
    ) ;_ end of DEFUN

    ;;;

    ;| from autocad help file |;
    (DEFUN pxto:inlist (inlist:lst inlist:str / inlist:ct tmpstr inlist:ret)
    (SETQ inlist:ct 0
    inlist:str
    (STRCASE inlist:str)
    ) ;_ end of SETQ
    (REPEAT (LENGTH inlist:lst) ;begin repeat
    (SETQ tmpstr (STRCASE (NTH inlist:ct inlist:lst)))
    (IF (WCMATCH tmpstr (STRCAT "*" inlist:str "*")) ;begin if
    (SETQ inlist:ret T)
    ) ;end if
    (SETQ inlist:ct (1+ inlist:ct))
    ) ;end repeat
    inlist:ret ;return T or nil
    ) ;_ end of DEFUN

    ;;;

    (DEFUN pxto:checkfile ()
    (IF (SETQ pxto:fil (OPEN (STRCAT (VL-FILENAME-DIRECTORY pxto:xrpathname)
    "\\"
    (VL-FILENAME-BASE pxto:xrpathname)
    ".dwl"
    ) ;_ end of STRCAT
    "r"
    ) ;_ end of OPEN
    ) ;_ end of SETQ
    (PROGN
    (SETQ pxto:user (READ-LINE pxto:fil))
    (CLOSE pxto:fil)
    (ALERT (STRCAT pxto:xrpathname
    "\n\nis currently in use by : \n\n"
    pxto:user
    "\n\nOpen has FAILED !!"
    ) ;_ end of STRCAT
    ) ;_ end of ALERT
    ) ;_ end of PROGN
    ;| ALERT |;
    (IF (DOS_FILEP pxto:xrpathname)
    (ALERT
    (STRCAT pxto:xrpathname "\n\nis currently in use !!\n\nOpen has
    FAILED !!")
    ) ;_ end of ALERT
    (ALERT (STRCAT pxto:xrpathname "\n\ndoes not exist !!\n\nOpen has
    FAILED !!")) ;_ end of ALERT
    ) ;_ end of IF
    ) ;_ end of IF
    ) ;_ end of DEFUN


    ;;;
    ;;; cridder
    (DEFUN c:pxto ;()
    (/ pxto:err pxto:ent pxto:dwg-dwgpath pxto:xref-vlaobj
    pxto:xref-name pxto:xref-name-dwg pxto:xref-path pxto:xrpathname
    pxto:fil pxto:user
    )
    (IF ;| from autocad help file |;
    (NOT (pxto:inlist (ARX) "whohas")) ;if statement is nil
    (SETQ pxto:err (ARXLOAD "whohas" nil)) ;then load arx
    ) ;_ end of IF
    (IF (DOS_XREFLIST)
    (PROGN
    (WHILE (NULL pxto:ent)
    (WHILE (NULL pxto:ent) (SETQ pxto:ent (ENTSEL "\n Pick XREF to
    OPEN")))
    (IF (OR (/= (STRCASE "INSERT") (CDR (ASSOC 0 (ENTGET (CAR
    pxto:ent)))))
    (NOT (pxto:isxref (CDR (ASSOC 2 (ENTGET (CAR pxto:ent))))))
    ) ;_ end of OR
    (PROGN (PRINC (STRCAT "\t The selected object was not a XREF.
    Please try again.") ;_ end of STRCAT
    ) ;_ end of PRINC
    (SETQ pxto:ent nil)
    ) ;_ end of PROGN
    (PROGN (SETQ pxto:dwg-dwgpath (STRCASE (GETVAR "dwgprefix")))
    (SETQ pxto:xref-vlaobj (VLAX-ENAME->VLA-OBJECT (CAR
    pxto:ent)))
    (SETQ pxto:xref-name (STRCASE (VLAX-GET-PROPERTY
    pxto:xref-vlaobj 'name)))
    (SETQ pxto:xref-name-dwg (STRCAT pxto:xref-name ".DWG"))
    (SETQ pxto:xref-path (STRCASE (VLAX-GET-PROPERTY
    pxto:xref-vlaobj 'path)))
    (COND ((VL-STRING-SEARCH ":" pxto:xref-path)
    (PROGN (SETQ pxto:xrpathname pxto:xref-path))
    )
    ((NOT (VL-STRING-SEARCH ":" pxto:xref-path))
    (PROGN (SETQ pxto:xrpathname (STRCAT
    pxto:dwg-dwgpath pxto:xref-path)))
    )
    ) ;_ end of COND
    (COND ((AND (DOS_FILEP pxto:xrpathname) (NOT (DOS_OPENP
    pxto:xrpathname)))
    (PROGN (pxto:eek:pendwg pxto:xrpathname))
    )
    ((DOS_OPENP pxto:xrpathname) (PROGN
    (pxto:checkfile)))
    ((NOT (DOS_FILEP pxto:xrpathname))
    (PROGN
    (IF (DOS_FILEP (STRCAT pxto:dwg-dwgpath
    (VL-FILENAME-BASE pxto:xref-path) ".dwg"))
    (PROGN (SETQ pxto:xrpathname (STRCAT
    pxto:dwg-dwgpath (VL-FILENAME-BASE pxto:xref-path) ".dwg"))
    (IF (AND (DOS_FILEP pxto:xrpathname) (NOT
    (DOS_OPENP pxto:xrpathname)))
    (pxto:eek:pendwg pxto:xrpathname)
    (pxto:checkfile)
    ) ;_ end of IF
    ) ;_ end of progn
    (PROGN (SETQ pxto:xrpathname (STRCAT
    pxto:dwg-dwgpath (VL-FILENAME-BASE pxto:xref-path) ".dwg"))
    (ALERT (STRCAT pxto:xrpathname "\n\ndoes
    not exist !!\n\nOpen has FAILED !!"))
    ) ;_ end of PROGN
    ) ;_ end of IF

    ) ;_ end of PROGN
    )
    ) ;_ end of COND
    ) ;_ end of PROGN
    ) ;_ end of IF
    ) ;_ end of WHILE
    ) ;_ end of PROGN
    (PROGN (ALERT "No XREF'S in this drawing !")
    ) ;_ end of PROGN
    ) ;_ end of IF
    (PRINC)
    ) ;_ end of DEFUN

    (PRINC)
     
    no.name, Jun 16, 2004
    #1
  2. no.name

    no.name Guest

    we are still on 2000i, that is why we need the routine.
     
    no.name, Jun 16, 2004
    #2
  3. no.name

    ECCAD Guest

    Observations:
    all the errors & users don't need all that chaecking.<<
    If that were the case, why even bother to have this routine ?
    Maybe add a little 'spell-check' too.
    Not very descriptive feedback.
    (STRCAT pxto:xrpathname "\n\nis currently in use !!\n\nOpen has
    FAILED !!")<<
    Very good.

    Baring a slight (insignificant) time required to execute, I would say your code is much more complete.

    Bob Shaw
    www.bobscadshop.com
     
    ECCAD, Jun 16, 2004
    #3
  4. no.name

    no.name Guest

    thanks for the comments.
    now i know i am not that insane.
    thanks.
     
    no.name, Jun 16, 2004
    #4
  5. if the manager cannot explain to you what he does not like, he does not know his programming!
    I try so hard to get my users to understand lisp, and to find one that wants to know, its a great opportunity.
    It really annoys me when some high and mighty Cad Manager bonehead does not take the time to help the people actually
    doing billable work.
    So keep learning and take his job in a few years.

    "no.name" <>
    |>i passed a function thats opens a picked xref, to the cad manager.
    |>
    |>i know there both not perfect, but lets compare them anyway.
    |>
    |>i was informed that my lisp does too much checking, autocad takes care of
    |>all the errors & users don't need all that chaecking.
    |>
    |>managers code is derived from the code i gave him.
    |>
    |>which one do you think does a better job ?
    |>
    |>help support a lonely old drafter.
    |>
    |>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    |>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    |>
    |>managers lisp
    |>
    |>(defun PickXrefOpen (/ olderr sel sdat)
    |> (errorsetup)
    |> (if
    |> (and
    |> (setq sel (entsel "\nSelect Xref: "))
    |> (eq "INSERT" (dxf 0 (setq sdat (entget (car sel)))))
    |> (not (null (pxo:xrefcheck (dxf 2 sdat)))))
    |> (progn
    |> (setq fnam (getfilepath (car sel)))
    |> (pxo:eek:pen fnam))
    |> (princ "\nNope."))
    |> (errorrestore)
    |>)
    |>
    |>(defun pxo:eek:pen (fil)
    |> (COMMAND
    |> "vbastmt"
    |> (STRCAT
    |> "AcadApplication.Documents.Open "
    |> (CHR 34)
    |> fil
    |> (CHR 34)
    |> )
    |> )
    |>)
    |>
    |>(DEFUN pxo:xrefcheck (bnam)
    |> (OR
    |> (=
    |> (VLA-GET-ISXREF
    |> (VLA-ITEM
    |> (VLA-GET-BLOCKS
    |> (VLA-GET-ACTIVEDOCUMENT
    |> (VLAX-GET-ACAD-OBJECT)))
    |> bnam
    |> )
    |> )
    |> :VLAX-TRUE
    |> )
    |> )
    |>)
    |>
    |>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    |>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    |>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    |>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    |>
    |>my lisp below
    |>
    |>;;;Open named drawing file (no error trapping is done!)
    |>;| From newsgroup, it rocks |;
    |>(DEFUN pxto:eek:pendwg (opendwg:fullname)
    |> (SETVAR "cmdecho" 0)
    |> (PRINC "\n")
    |> (COMMAND "vbastmt"
    |> (STRCAT "AcadApplication.Documents.Open " (CHR 34)
    |>opendwg:fullname (CHR 34))
    |> ) ;_ end of COMMAND
    |> (SETVAR "cmdecho" 1)
    |> (PRINC (STRCAT "\n " pxto:xrpathname " was opened."))
    |> (PRINC)
    |> ) ;_ end of DEFUN
    |>
    |>;;;
    |>
    |>;|From newsgroup, it rocks |;
    |>(DEFUN pxto:isxref (isxref:bname)
    |> (OR
    |> (= (VLA-GET-ISXREF
    |> (VLA-ITEM (VLA-GET-BLOCKS (VLA-GET-ACTIVEDOCUMENT
    |>(VLAX-GET-ACAD-OBJECT))) ;_ end of VLA-GET-BLOCKS
    |> isxref:bname
    |> ) ;_ end of VLA-ITEM
    |> ) ;_ end of VLA-GET-ISXREF
    |> :VLAX-TRUE
    |> ) ;_ end of =
    |> ) ;_ end of OR
    |> ) ;_ end of DEFUN
    |>
    |>;;;
    |>
    |>;| from autocad help file |;
    |>(DEFUN pxto:inlist (inlist:lst inlist:str / inlist:ct tmpstr inlist:ret)
    |> (SETQ inlist:ct 0
    |> inlist:str
    |> (STRCASE inlist:str)
    |> ) ;_ end of SETQ
    |> (REPEAT (LENGTH inlist:lst) ;begin repeat
    |> (SETQ tmpstr (STRCASE (NTH inlist:ct inlist:lst)))
    |> (IF (WCMATCH tmpstr (STRCAT "*" inlist:str "*")) ;begin if
    |> (SETQ inlist:ret T)
    |> ) ;end if
    |> (SETQ inlist:ct (1+ inlist:ct))
    |> ) ;end repeat
    |> inlist:ret ;return T or nil
    |> ) ;_ end of DEFUN
    |>
    |>;;;
    |>
    |>(DEFUN pxto:checkfile ()
    |> (IF (SETQ pxto:fil (OPEN (STRCAT (VL-FILENAME-DIRECTORY pxto:xrpathname)
    |> "\\"
    |> (VL-FILENAME-BASE pxto:xrpathname)
    |> ".dwl"
    |> ) ;_ end of STRCAT
    |> "r"
    |> ) ;_ end of OPEN
    |> ) ;_ end of SETQ
    |> (PROGN
    |> (SETQ pxto:user (READ-LINE pxto:fil))
    |> (CLOSE pxto:fil)
    |> (ALERT (STRCAT pxto:xrpathname
    |> "\n\nis currently in use by : \n\n"
    |> pxto:user
    |> "\n\nOpen has FAILED !!"
    |> ) ;_ end of STRCAT
    |> ) ;_ end of ALERT
    |> ) ;_ end of PROGN
    |> ;| ALERT |;
    |> (IF (DOS_FILEP pxto:xrpathname)
    |> (ALERT
    |> (STRCAT pxto:xrpathname "\n\nis currently in use !!\n\nOpen has
    |>FAILED !!")
    |> ) ;_ end of ALERT
    |> (ALERT (STRCAT pxto:xrpathname "\n\ndoes not exist !!\n\nOpen has
    |>FAILED !!")) ;_ end of ALERT
    |> ) ;_ end of IF
    |> ) ;_ end of IF
    |> ) ;_ end of DEFUN
    |>
    |>
    |>;;;
    |>;;; cridder
    |>(DEFUN c:pxto ;()
    |> (/ pxto:err pxto:ent pxto:dwg-dwgpath pxto:xref-vlaobj
    |>pxto:xref-name pxto:xref-name-dwg pxto:xref-path pxto:xrpathname
    |> pxto:fil pxto:user
    |> )
    |> (IF ;| from autocad help file |;
    |> (NOT (pxto:inlist (ARX) "whohas")) ;if statement is nil
    |> (SETQ pxto:err (ARXLOAD "whohas" nil)) ;then load arx
    |> ) ;_ end of IF
    |> (IF (DOS_XREFLIST)
    |> (PROGN
    |> (WHILE (NULL pxto:ent)
    |> (WHILE (NULL pxto:ent) (SETQ pxto:ent (ENTSEL "\n Pick XREF to
    |>OPEN")))
    |> (IF (OR (/= (STRCASE "INSERT") (CDR (ASSOC 0 (ENTGET (CAR
    |>pxto:ent)))))
    |> (NOT (pxto:isxref (CDR (ASSOC 2 (ENTGET (CAR pxto:ent))))))
    |> ) ;_ end of OR
    |> (PROGN (PRINC (STRCAT "\t The selected object was not a XREF.
    |>Please try again.") ;_ end of STRCAT
    |> ) ;_ end of PRINC
    |> (SETQ pxto:ent nil)
    |> ) ;_ end of PROGN
    |> (PROGN (SETQ pxto:dwg-dwgpath (STRCASE (GETVAR "dwgprefix")))
    |> (SETQ pxto:xref-vlaobj (VLAX-ENAME->VLA-OBJECT (CAR
    |>pxto:ent)))
    |> (SETQ pxto:xref-name (STRCASE (VLAX-GET-PROPERTY
    |>pxto:xref-vlaobj 'name)))
    |> (SETQ pxto:xref-name-dwg (STRCAT pxto:xref-name ".DWG"))
    |> (SETQ pxto:xref-path (STRCASE (VLAX-GET-PROPERTY
    |>pxto:xref-vlaobj 'path)))
    |> (COND ((VL-STRING-SEARCH ":" pxto:xref-path)
    |> (PROGN (SETQ pxto:xrpathname pxto:xref-path))
    |> )
    |> ((NOT (VL-STRING-SEARCH ":" pxto:xref-path))
    |> (PROGN (SETQ pxto:xrpathname (STRCAT
    |>pxto:dwg-dwgpath pxto:xref-path)))
    |> )
    |> ) ;_ end of COND
    |> (COND ((AND (DOS_FILEP pxto:xrpathname) (NOT (DOS_OPENP
    |>pxto:xrpathname)))
    |> (PROGN (pxto:eek:pendwg pxto:xrpathname))
    |> )
    |> ((DOS_OPENP pxto:xrpathname) (PROGN
    |>(pxto:checkfile)))
    |> ((NOT (DOS_FILEP pxto:xrpathname))
    |> (PROGN
    |> (IF (DOS_FILEP (STRCAT pxto:dwg-dwgpath
    |>(VL-FILENAME-BASE pxto:xref-path) ".dwg"))
    |> (PROGN (SETQ pxto:xrpathname (STRCAT
    |>pxto:dwg-dwgpath (VL-FILENAME-BASE pxto:xref-path) ".dwg"))
    |> (IF (AND (DOS_FILEP pxto:xrpathname) (NOT
    |>(DOS_OPENP pxto:xrpathname)))
    |> (pxto:eek:pendwg pxto:xrpathname)
    |> (pxto:checkfile)
    |> ) ;_ end of IF
    |> ) ;_ end of progn
    |> (PROGN (SETQ pxto:xrpathname (STRCAT
    |>pxto:dwg-dwgpath (VL-FILENAME-BASE pxto:xref-path) ".dwg"))
    |> (ALERT (STRCAT pxto:xrpathname "\n\ndoes
    |>not exist !!\n\nOpen has FAILED !!"))
    |> ) ;_ end of PROGN
    |> ) ;_ end of IF
    |>
    |> ) ;_ end of PROGN
    |> )
    |> ) ;_ end of COND
    |> ) ;_ end of PROGN
    |> ) ;_ end of IF
    |> ) ;_ end of WHILE
    |> ) ;_ end of PROGN
    |> (PROGN (ALERT "No XREF'S in this drawing !")
    |> ) ;_ end of PROGN
    |> ) ;_ end of IF
    |> (PRINC)
    |> ) ;_ end of DEFUN
    |>
    |>(PRINC)
    |>
    |>
    |>

    James Maeding
    Civil Engineer/Programmer
     
    James Maeding, Jun 17, 2004
    #5
  6. no.name

    no.name Guest

    thanks for the encouragement. don't know if the company will be able to
    afford me if that opportunity comes up.

    thanks
     
    no.name, Jun 17, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.