Visual LISP, AutoLISP and General Customization

Reply
Contributor
CheleCity
Posts: 16
Registered: ‎08-08-2012
Message 1 of 9 (196 Views)

Group center marks?

196 Views, 8 Replies
05-09-2013 05:54 AM

Anybody ever write a routine that would group center marks after using dimcenter?  Thanks.

Distinguished Mentor
_Tharwat
Posts: 574
Registered: ‎07-02-2010
Message 2 of 9 (190 Views)

Re: Group center marks?

05-09-2013 06:28 AM in reply to: CheleCity

Try this code and let me know how things get on with you .

 

(defun c:Marks (/ *error* cross o c l ss i)
  ;; --- Tharwat 09. May. 2013 ---;;
  (defun *error* (x)
    (if o
      (setvar 'osmode o)
    )
    (if c
      (setvar 'cmdecho c)
    )
    (princ "\n*Cancel*")
  )
  (defun cross (pt l / a b c d)

    (entmakex
      (list
        (cons 0 "LINE")
        (cons 10 (setq a (trans (polar pt (/ pi 2.) (/ l 2)) 1 0)))
        (cons 11
              (setq b (trans (polar pt (/ (* 3. pi) 2.) (/ l 2)) 1 0))
        )
      )
    )
    (entmakex
      (list (cons 0 "LINE")
            (cons 10 (setq c (trans (polar pt 0 (/ l 2)) 1 0)))
            (cons 11 (setq d (trans (polar pt pi (/ l 2)) 1 0)))
      )
    )
  )
  (setq o (getvar 'osmode)
        c (getvar 'cmdecho)
        l (getvar 'dimcen)
  )
  (mapcar 'setvar '(osmode cmdecho) (list 0 0))
  (if (setq ss (ssget '((0 . "CIRCLE,ARC"))))
    (repeat (setq i (sslength ss))
      (setq e (entget (ssname ss (setq i (1- i)))))
      (cross (cdr (assoc 10 e)) (* l 2.))
    )
  )
  (*error* nil)
  (princ "\n Written by Tharwat Al Shoufi")
  (princ)
)


 

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Contributor
CheleCity
Posts: 16
Registered: ‎08-08-2012
Message 3 of 9 (183 Views)

Re: Group center marks?

05-09-2013 06:46 AM in reply to: _Tharwat

It drew some tick marks on a random place on the screen, and they weren't grouped.  Sorry

Distinguished Mentor
_Tharwat
Posts: 574
Registered: ‎07-02-2010
Message 4 of 9 (180 Views)

Re: Group center marks?

05-09-2013 06:48 AM in reply to: CheleCity

CheleCity wrote:

It drew some tick marks on a random place on the screen, and they weren't grouped.  Sorry


What do you mean by group ?

Upload a sample drawing showing your task before and after .

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Contributor
CheleCity
Posts: 16
Registered: ‎08-08-2012
Message 5 of 9 (174 Views)

Re: Group center marks?

05-09-2013 07:13 AM in reply to: _Tharwat

I mean the "Group" function.  When you group something, when you select something one item in the group, it will select all of them.

Contributor
CheleCity
Posts: 16
Registered: ‎08-08-2012
Message 6 of 9 (172 Views)

Re: Group center marks?

05-09-2013 07:16 AM in reply to: CheleCity

There is no need to upload drawing.  Center marks are common items.  I would just like them to be grouped instead of individual lines, especially when you using negative dimcenter value.  With negative dimcenter values (like I like to use), the dimcenter command will generate 6 seperate lines to mark the circle center

Mentor
stevor
Posts: 835
Registered: ‎12-26-2005
Message 7 of 9 (140 Views)

Re: Group center marks?

05-13-2013 03:54 AM in reply to: CheleCity

 

This is for the 2 LINE dimcenter construct;

modify to suit yours.

 

Usually a BLOCK is used instead of the LINEs,

more useful.

 

For LWPOLYLINES, or INSERTs,  other code must be used.

 

(defun dxf_ (n alst) (cdr (assoc n alst)) ) 
 
 (DeFun dxf_EU (gn edL / vv ) ; return Ucs coords
  (if (and (setq vv (cdr (assoc gn edL)))
           (member gn (list 10 11 210 ))) ; others may exist!
    (trans vv (cdr (assoc -1 edl)) 1) vv ) )
    
(defun c:dcg (/ SS)  ;  stevor 13MAY13
  (if (and (setq len1 (entlast) ; ref db ent
                 es (entsel " Sel ARC,CIRCLE"))
           (setq sen (car es)  ty (dxf_ 0 (entget sen)))
           (or (member ty (list "ARC" "CIRCLE"))
            (and (princ "\n Ty: ")(princ ty) nil)) )
   (progn  
    (command "DIMCENTER" es )
    (if (/= len1 (entlast) )
     (progn  (princ " grouper ")
      (setq en2 (entnext len1)  en3 (entnext en2)
            es2 (list en2 (dxf_eu 10 (entget en2)))
            es3 (list en3 (dxf_eu 10 (entget en3))) )
      (command "-group" "C" "*" "" es2 es3 "" )
     )
    )
    (princ" Ty: ")(prin1 (dxf_ 0 (entget sen)))  ) ) (princ) )
    
    (  c:dcg   )
    
(princ" done" ))

S
*Expert Elite*
Kent1Cooper
Posts: 5,242
Registered: ‎09-13-2004
Message 8 of 9 (129 Views)

Re: Group center marks?

05-13-2013 06:46 AM in reply to: CheleCity

CheleCity wrote:

Anybody ever write a routine that would group center marks after using dimcenter?  Thanks.


Here's my take on it:

 

(defun C:smileyvery-happy:CG (/ last dcgss); = DimCenter with Grouping of resulting lines
  (setq
    last (entlast)
    dcgss (ssadd)
  ); setq
  (if (/= (getvar 'dimcen) 0)
    (progn ; then
      (command "_.dimcenter")
      (while (> (getvar 'cmdactive) 0) (command pause))
        ; allows for missed pick, wrong object type, etc.
      (while (setq last (entnext last)); whether 2 or 6 Lines
        (ssadd last dcgss); add them to selection
      ); while
      (command "_.group" "" "*" "" dcgss ""); make into unnamed Group
    ); progn
    (alert "DIMCEN System Variable must be non-zero."); else
  ); if
  (princ)
); defun

Kent Cooper
Contributor
CheleCity
Posts: 16
Registered: ‎08-08-2012
Message 9 of 9 (121 Views)

Re: Group center marks?

05-13-2013 07:47 AM in reply to: Kent1Cooper

Thanks!  Good stuff.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community