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

Could you please help with Lisp

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
811 Views, 2 Replies

Could you please help with Lisp

Hi there

 

Looking for a LISP routine for labeling Layer name and Length of Polyline in a box with arrow ( SEE ATTACHED )

 

Please help

 

2 REPLIES 2
Message 2 of 3
ВeekeeCZ
in reply to: Anonymous

Just quickly adjusted the routine what I have...

It uses a current mleader style - with two vertices - real design is up to you.

 

(vl-load-com)

;   based on Lee Mac  ~  29.04.10
(defun c:LengthAtMidpoint ( / *error* spc i ss e Der p obj )
  
  (defun *error* ( msg )
    (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
        (princ (strcat "\n** Error: " msg " **")))
    (princ)
    )
  
  (setq spc (if (or (eq AcModelSpace (vla-get-ActiveSpace (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))))
                    (eq :vlax-true (vla-get-MSpace doc)))
              (vla-get-ModelSpace doc)
              (vla-get-PaperSpace doc)))
  
  (if (setq i -1
            ss (ssget '((0 . "CIRCLE,ARC,LINE,*POLYLINE"))))
    
    (while (setq e (ssname ss (setq i (1+ i))))
      (setq Der (angle '(0. 0. 0.) (vlax-curve-getFirstDeriv e (vlax-curve-getParamatPoint e (setq p (MidPoint e)))))
            Obj (MCMLeader p (strcat (cdr (assoc 8 (entget e)))
                                     "\\P"
                                     "%<\\AcObjProp Object(%<\\_ObjId "
                                     (GetObjectID (vlax-ename->vla-object e) doc) ">%)."
                                     (cond ((eq "CIRCLE" (setq typ (cdr (assoc 0 (entget e)))))
                                            "Circumference")
                                           ((eq "ARC" typ)
                                            "ArcLength")
                                           ("Length"))
                                     " \\f \"%lu6%pr1\">%"
                                     "m")))
      ;(vla-put-rotation Obj (MakeReadable Der))
      ;(vla-put-BackgroundFill obj :vlax-true)
      ))
  (princ)
  )


(defun MCMText (block point width string / o)
  (vla-put-AttachmentPoint
    (setq o (vla-AddMText block
              (vlax-3D-point point) width string))
    acAttachmentPointMiddleCenter)
  (vla-put-InsertionPoint o (vlax-3D-point point))
  
  o)

(defun MCMLeader (point str / )
  (command "_.MLEADER"
           "_none" point
           "_none" (polar point (/ pi 4)
                          5 			; <---  SET DISTANCE
                          ) str))

(defun MakeReadable ( a )
  (cond ((and (> a (/ pi 2)) (<= a pi))
         (- a pi))
        ((and (> a pi) (<= a (/ (* 3 pi) 2)))
         (+ a pi))
        (a)))

(defun GetObjectID ( obj doc )
  (if (eq "X64" (strcase (getenv "PROCESSOR_ARCHITECTURE")))
    (vlax-invoke-method
      (vla-get-Utility doc) 'GetObjectIdString obj :vlax-false)
    (itoa (vla-get-Objectid obj))))

(defun MidPoint ( e )
  (vlax-curve-getPointatDist e (/ (vlax-curve-getDistatParam e
                                    (vlax-curve-getEndParam e))
                                  2.)))

 

Message 3 of 3
Anonymous
in reply to: ВeekeeCZ

Wonderfull = thank you

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report