Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Group center marks?

8 REPLIES 8
Reply
Message 1 of 9
CheleCity
416 Views, 8 Replies

Group center marks?

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

8 REPLIES 8
Message 2 of 9
_Tharwat
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)
)


 

Message 3 of 9
CheleCity
in reply to: _Tharwat

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

Message 4 of 9
_Tharwat
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 .

Message 5 of 9
CheleCity
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.

Message 6 of 9
CheleCity
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

Message 7 of 9
stevor
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
Message 8 of 9
Kent1Cooper
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:DCG (/ 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, AIA
Message 9 of 9
CheleCity
in reply to: Kent1Cooper

Thanks!  Good stuff.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost