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

Xline creating issue...

8 REPLIES 8
Reply
Message 1 of 9
danglar
823 Views, 8 Replies

Xline creating issue...

I try to divide  POLYLINEs, LINEs, CIRCLEs, ELLIPSEs, SPLINEs and ARCs according to light poles distribution purposes. It's become possible if I draw dividing line (see my modification of Tharwat code)

;;; Divide POLYLINEs,LINEs,CIRCLEs,ELLIPSEs,SPLINEs and ARCs according to light poles distribution purposes
;;; Modified by Igal Averbuh  2018 (added optilon  x/2 x x x/2 divide for lighting purposes)
;;; Created by ;;; Tharwat 02. Jan. 2013 ;;;
;;; Saved from: https://www.cadtutor.net/forum/topic/43505-help-modifying-a-modified-divide-lisp-from-cadalyst-website/

(defun c:AD (/ s n j sn d i l pt ang)
 (vl-load-com)

 (if (and (setq n (getint "\n Number of segments :"))
          (setq s (ssget '((0 . "*POLYLINE,LINE,CIRCLE,ELLIPSE,SPLINE,ARC"))))
     )
   (if (not (eq n 0))
     (repeat (setq j (sslength s))
       (setq sn (ssname s (setq j (1- j))))
       (setq d (/ (vlax-curve-getdistatparam sn (vlax-curve-getendparam sn)) n)
             i (* d 0.5)
             l (/ d 10.)
       )
       (repeat n
         (setq pt (vlax-curve-getpointatdist sn i))
         (setq ang (angle '(0.0 0.0 0.0) (vlax-curve-getfirstderiv sn (vlax-curve-getparamatpoint sn pt))))
		 
		 (entmake
            (list
              '(0 . "XLINE")
              '(100 . "AcDbEntity")
              '(100 . "AcDbXline")
              (cons 10 (polar pt (+ ang (/ pi 2.)) l))
              (cons 11 (polar pt (- ang (/ pi 2.)) l))
            )
          )
		 
		 
         ;(entmakex (list '(0 . "LINE")
                         ;(cons 10 (polar pt (+ ang (/ pi 2.)) l))
                         ;(cons 11 (polar pt (- ang (/ pi 2.)) l))
                   ;)
        ;)
		 
		 ;(command "_.XLINE" "_B")

		 
		 
         (setq i (+ d i))
       )
     )
     (alert "Number of segments must be bigger than ZERO !!")
   )
 )
 (princ)
)
(c:ad)

I did another step and now I need to divide it by xlines

 

It become possible if I use (command "_.XLINE" "_B")

when starting and direction vector points are:

(cons 10 (polar pt (+ ang (/ pi 2.)) l))

 (cons 11 (polar pt (- ang (/ pi 2.)) l))

.. but my attempt to add it to lisp was unsuccessful

can somebody help me to do it?

The main goal is - to create xlines in division points..

Any help will be very appreciated

8 REPLIES 8
Message 2 of 9
Š’eekeeCZ
in reply to: danglar

Try this one:

  (defun :makexline (pt ang /)
    (entmakex (list (cons 0   "XLINE")
		    (cons 100 "AcDbEntity")
		    (cons 100 "AcDbXline")
		    (cons 10  pt)
		    (cons 11  (polar '(0 0 0) ang 1)))))
Message 3 of 9
danglar
in reply to: Š’eekeeCZ

Untitled.jpg

Thanks to your attention to my post and your rapid answer

but unfortunately it nor work as I expected

see attached lisp:

 

Message 4 of 9
Š’eekeeCZ
in reply to: danglar

Ok, I'll give you some time to think about it. You don't really have to be Einstein.

Message 5 of 9
danglar
in reply to: Š’eekeeCZ

Ok,

My guess: now all xlines have tangent direction to divided entity and we need to draw it perpendicular to it..

Difference between tangent and perpendicular line is 90 degree

Conclusion: need to change this string:

(cons 11  (polar '(0 0 0) ang 1)))))

in order to rotate xline to 90 degree..

How to do it?

Message 6 of 9
danglar
in reply to: danglar

and here a solution:

(cons 11  (polar '(0 0 0) (- ang (/ pi 2.)) 1))))

Message 7 of 9
danglar
in reply to: danglar
Message 8 of 9
Š’eekeeCZ
in reply to: danglar

One more note. See THIS list. These are names of C3D transparent commands, which cannot be redefined by LISP.

If the name of your routine is upon that list, it won't work for C3D users.

So if your (potential) end users are also C3D users, consider using more complex names for your routines.

Message 9 of 9
danglar
in reply to: Š’eekeeCZ

very interesting remark
I didn't even think about it..

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

Post to forums  

Autodesk Design & Make Report

ā€Boost