Results 1 to 3 of 3

Thread: Need help with this code

  1. #1
    Member
    Join Date
    2014-10
    Posts
    17
    Login to Give a bone
    0

    Default Need help with this code

    Hey all you Lisp Wizards!

    Ok... so here's what I need.... I need a lisp routine that will allow me to select multiple 3D Solid extrusions and allow me to list the "Height" data from the extrusion to build a BOM of sorts. Even an overall or cumulative length would be helpful! All of the extrusions are the same. I have been modifying some code I found online, but have reached the limits of my Lisp knowledge (which took about 5 minutes!) Here is the code as it currently stands.

    Code:
    (defun C:BOM (/ intCount entSelection objSelection ssSelections )
    
    
    (setq solent (entsel "\nSelect solid : "))
    (setq slist (entget (car solent)))
    (setq extvector (cdr (assoc 10
    			    (entget (cdr (assoc 360
    						(entget (cdr (assoc 360
    								    (entget (cdr (assoc 350 slist))))))))))))
    (setq extHeight (sqrt (apply '+(mapcar '* extvector extvector))))
    (alert (vl-princ-to-string extHeight))
    
    
       )
      )
     )
     (princ)
    )
    Any help would be greatly appreciated!!!

    Regards,
    MT
    Last edited by rkmcswain; 2018-07-13 at 08:46 PM. Reason: Added [CODE] tags

  2. #2
    I could stop if I wanted to
    Join Date
    2002-08
    Posts
    231
    Login to Give a bone
    0

    Default Re: Need help with this code

    Perhaps, with not guaranted...
    For primitive of 3DSolid only
    Code:
    (defun C:BOM ( / js n Solid idHistory History idEvalGraph EvalGraph idEvalExpr EvalExpr typ_sol key)
      (princ "\nSelect Primitive 3DSolid: ")
      (while (null (setq js (ssget '((0 . "3DSOLID"))))))
      (repeat (setq n (sslength js))
        (setq
          Solid (entget (ssname js (setq n (1- n))))
          idHistory (cdr (assoc 350 (member '(100 . "AcDb3dSolid") Solid)))
        )
        (cond
          ((setq History (entget idHistory))
            (setq
              idEvalGraph (cdr (assoc 360 (member '(100 . "AcDbShHistory") History)))
              EvalGraph (entget idEvalGraph)
              idEvalExpr (cdr (assoc 360 (member '(100 . "AcDbEvalGraph") EvalGraph)))
            )
            (cond
              (idEvalExpr
                (setq
                  EvalExpr (entget idEvalExpr)
                  typ_sol (substr (cdr (assoc 100 (reverse EvalExpr))) 7)
                  key
                  (cond
                    ((eq typ_sol "Extrusion") 10)
                    ((eq typ_sol "Torus") 41)
                    ((or (eq typ_sol "Box") (eq typ_sol "Wedge")) 42)
                    ((or (eq typ_sol "Cylinder") (eq typ_sol "Pyramid") (eq typ_sol "Cone") (eq typ_sol "Sphere")) 40)
                  )
                )
                (if (member typ_sol '("Extrusion" "Torus" "Box" "Wedge" "Cylinder" "Pyramid" "Cone" "Sphere"))
                  (princ
                    (strcat
                      "\n"
                      typ_sol
                      "\tHeight :"
                      (rtos 
                        (* (if (or (eq typ_sol "Torus") (eq typ_sol "Sphere")) 2.0 1.0)
                         ((if (eq typ_sol "Extrusion") cadddr cdr) (assoc key (reverse EvalExpr)))
                        )
                      )
                      "\n"
                    )
                  )
                )
              )
            )
          )
        )
      )
      (prin1)
    )

  3. #3
    I could stop if I wanted to
    Join Date
    2005-06
    Location
    CORDOBA-ARGENTINA
    Posts
    275
    Login to Give a bone
    0

    Default Re: Need help with this code

    A sample.dwg , from you , will help much more.ç

Similar Threads

  1. Allow Other Code Compilers for ARX Code
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2013-02-10, 08:06 AM
  2. Help With Code Please
    By CADdancer in forum AutoLISP
    Replies: 3
    Last Post: 2009-08-17, 09:34 PM
  3. Insert vbscript code has not code
    By buzz in forum AMEP General
    Replies: 3
    Last Post: 2008-02-09, 03:08 AM
  4. Convert VBA code to VB code
    By Robert Platt in forum VBA/COM Interop
    Replies: 20
    Last Post: 2007-08-15, 10:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •