Xline creating issue...

Xline creating issue...

danglar
Advocate Advocate
1,053 Views
8 Replies
Message 1 of 9

Xline creating issue...

danglar
Advocate
Advocate

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

0 Likes
1,054 Views
8 Replies
Replies (8)
Message 2 of 9

ВeekeeCZ
Consultant
Consultant

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)))))
0 Likes
Message 3 of 9

danglar
Advocate
Advocate

Untitled.jpg

Thanks to your attention to my post and your rapid answer

but unfortunately it nor work as I expected

see attached lisp:

 

0 Likes
Message 4 of 9

ВeekeeCZ
Consultant
Consultant

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

0 Likes
Message 5 of 9

danglar
Advocate
Advocate

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?

0 Likes
Message 6 of 9

danglar
Advocate
Advocate

and here a solution:

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

Message 7 of 9

danglar
Advocate
Advocate
0 Likes
Message 8 of 9

ВeekeeCZ
Consultant
Consultant

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
Advocate
Advocate

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

0 Likes