Author Topic: (help) to construct classification, statistics the number of.  (Read 1746 times)

0 Members and 1 Guest are viewing this topic.

Q1241274614

  • Guest
(help) to construct classification, statistics the number of.
« on: February 28, 2013, 06:29:25 AM »
(help) to construct classification, statistics the number of.

(DEFUN C:TT( / a ang b er1 er2 er3 l p  q r r1 r2)
  (vl-load-com)
  (setq p  (getpoint "\nSTA "))
  (setq q  (getpoint p "\nEND "))
  (setq l  300)
  (setq ang (angle p q))
  (setq r  (getdist "\nGG-radius"))
  (setq r1 (getdist "\nSTA-radius"))
  (setq r2 (getdist "\nEND-radius"))
  (if (null r)  (setq r 50))
  (if (null r1)  (setq r1 70))
  (if (null r2)  (setq r2 60))
  (setq er1 (cylinder p q r))
  (setq er2 (cylinder (polar p (+ (* pi 0.5) ang) l)(polar p (-  ang (* pi 0.5)) l) r1))
  (setq er3 (cylinder (polar q (+ (* pi 0.5) ang) l)(polar q (-  ang (* pi 0.5)) l) r2))
  (vlax-ldata-put er1 "GG" (strcat (itoa (fix (distance p q))) "X"(rtos r 2 0)))
  (vlax-ldata-put er2 "ZG" (strcat (itoa l) "X"(rtos r1 2 0)))
  (vlax-ldata-put er3 "ZG" (strcat (itoa l) "X"(rtos r2 2 0)))
  (princ)
)

(defun cylinder (p q r)
  (defun mxv ( m v )
    (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
)
  (setq vec (mapcar '- q p)
   obj (vla-addcylinder (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) (vlax-3D-point p) r (setq hgt (distance p q)))
        mat (mapcar '(lambda ( v ) (trans v 0 vec t)) '((1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0)))
  )
(vla-transformby obj
                (vlax-tmatrix
                    (append
                        (mapcar 'append mat
                            (mapcar 'list
                                (mapcar '+ (trans (list 0.0 0.0 (/ hgt 2.0)) vec 0 t)
                                    (mapcar '- p (mxv mat p))
                                )
                            )
                        )
                     
                       '((0.0 0.0 0.0 1.0))
                    )
                )
            )
  obj
  )


(vl-load-com) (princ)
« Last Edit: February 28, 2013, 07:36:05 AM by Q1241274614 »

Q1241274614

  • Guest
Re: (help) to construct classification, statistics the number of.
« Reply #1 on: February 28, 2013, 07:38:58 AM »
(help) to construct classification, statistics the number of.

fixo

  • Guest
Re: (help) to construct classification, statistics the number of.
« Reply #2 on: February 28, 2013, 11:25:01 AM »
Here is quickly written framework,
continue them to your suit:

Code: [Select]
(defun C:ZGX(/ suminlist data elist en info loop lst p1 p2 part pos
     row rows sset sumdata tabledata tmp txt typ types x)

;;  helper:
;;  group with sum elements in list   
;;  fixo () 2006 * all rights released
(defun suminlist  (lst)
  (if (car lst)
    (cons (cons (car lst)
(length (vl-remove-if-not
  '(lambda (x) (equal (car lst) x 0.001))
  lst)
)
)
  (suminlist (vl-remove-if
       '(lambda (x)
  (equal (car lst) x 0.001))
       lst)
     )
  )
    )
  )
;; usage: (setq groups (suminlist lst))


;; main part ;;;

(setq tabledata nil)
(setq loop T)
(while loop
;; select every frame by window separatelly include the text above frame
(if (and (setq p1 (getpoint "\n Lower left corner point (press Enter to Exit loop): "))
(setq p2 (getcorner p1"\n Opposite corner (incude \"XG\" marker) : ")))
  (progn
(setq sset (ssget "w" p1 p2 (list (cons 0  "text" ))))
(progn

(while (setq en ( ssname sset 0))
     (setq elist (entget en))
  (setq txt (cdr (assoc 1 elist)))
  (setq info (cons txt info))
  (ssdel en sset)
  )
(setq typ (car (vl-remove-if '(lambda (st)(wcmatch st  "*->*"))info)))
(setq types (vl-remove-if-not '(lambda (st)(wcmatch st  "*->*"))info))
(setq types (mapcar '(lambda (x)
       (setq pos (vl-string-search "->" x))
       (setq x (substr x (+ pos (1+ (strlen "->")))))) types))
(setq part (append (list typ)(list types)))
(setq tabledata (append  tabledata (list part)))
(setq info nil types nil part nil)

  )
)
  (setq loop nil)))

(if tabledata
  (progn
   
    ;; group items
    (setq data nil)
(while (setq tmp (car tabledata))
       (setq lst (cdr tmp))
  (setq rows (vl-remove-if-not '(lambda (x)(eq (car x) (car tmp))) tabledata))
  (setq row (append (list (car tmp)) (apply 'append(apply 'append (mapcar 'cdr rows)))))
  (setq data (cons row data))
  (setq tabledata (vl-remove-if '(lambda (x)(eq (car x) (car tmp))) tabledata)))

(setq sumdata nil)
(foreach item data
(setq sumdata (cons (append (list (car item))(suminlist (cdr item))) sumdata)))
(print sumdata)(princ "\n")
   
    ;; do next by yourself:
   
    ;; 1. pick point to insert table

    ;; 2. add table

    ;; 3. populate table
   
    ;; etc etc...
   
    )
 
  )
(princ)
  )
(princ "\n Type ZGX to start program")
(prin1)

Q1241274614

  • Guest
Re: (help) to construct classification, statistics the number of.
« Reply #3 on: February 28, 2013, 10:20:38 PM »
Thank you, your answer!I hope that through belt (vlax-ldata-put) extended data entity (3DSOLID), according to each different classification, the number of statistics.

(defun C:QQ ( / )
  (vl-load-com)
  (SETQ EN (vlax-ename->vla-object (car (entsel ))))
  (PRINC (vlax-ldata-get EN "GG"))
  (PRINC (vlax-ldata-get EN "ZG"))
  (PRINC)
)


The original file as follows

Q1241274614

  • Guest
Re: (help) to construct classification, statistics the number of.
« Reply #4 on: February 28, 2013, 10:23:28 PM »
thank!

fixo

  • Guest
Re: (help) to construct classification, statistics the number of.
« Reply #5 on: March 01, 2013, 12:45:54 AM »
Sorry, I have not have a time to to help you further
Ask somebody else to play with this stuff  :realmad:

xiaxiang

  • Guest
Re: (help) to construct classification, statistics the number of.
« Reply #6 on: March 01, 2013, 11:59:20 PM »
Sorry but what do you want? You can continue with the fixo's code if you have mastered autoLISP,or not you should express the matter with which step...