Change the step

Change the step

Anonymous
Not applicable
1,053 Views
8 Replies
Message 1 of 9

Change the step

Anonymous
Not applicable

Hi Team,

 

Could anyone help me on this step, I want to specify n number of points, here is the step need to change "(setq p1 (getpoint "\nSpecify the point A: "))".

 

(defun c:cbline ( / en ex e1 e2 el p1 q1 p2 q2 pe ps la)

(if (and (setq *c2p-en* (cond ((car (entsel (strcat "\nSelect axis polyline " (if *c2p-en* " <last>" ": ")))))
(*c2p-en*)))
(= "LWPOLYLINE" (cdr (assoc 0 (entget *c2p-en*))))
(setq p1 (getpoint "\nSpecify the point A: "))
(setq p1 (trans p1 1 0))
(setq q1 (vlax-curve-getClosestPointTo *c2p-en* p1))
(setq p2 (getpoint "\nSpecify the point B: "))
(setq p2 (trans p2 1 0))
(setq q2 (vlax-curve-getClosestPointTo *c2p-en* p2))
(setq ps (vlax-curve-getStartPoint *c2p-en*))
(setq pe (vlax-curve-getEndPoint *c2p-en*))
)
(progn
(setq la "test")
(command ".-LAYER" "_New" la "_Color" 2 la "")
(setq en (entmakex (append (entget *c2p-en*)
(list (cons 8 la)))))
(setq el (entlast))
(and (not (equal q1 pe 1e-6))
(not (equal q1 ps 1e-6))
(vl-cmdf "_.BREAK" en "_none" (trans q1 0 1) "_none" (trans q1 0 1))
(not (equal el (entlast)))
(setq ex (entlast))
)
(if (equal q2 (vlax-curve-getClosestPointTo en q2) 1e-6)
(if ex (entdel ex))
(progn
(entdel en)
(setq en ex)))
(setq ex nil
el (entlast))
(and (not (equal q2 pe 1e-6))
(not (equal q2 ps 1e-6))
(vl-cmdf "_.BREAK" en "_none" (trans q2 0 1) "_none" (trans q2 0 1))
(not (equal el (entlast)))
(setq ex (entlast))
)
(if (and (or (equal q1 (vlax-curve-getStartPoint en) 1e-6)
(equal q1 (vlax-curve-getEndPoint en) 1e-6))
(or (equal q2 (vlax-curve-getStartPoint en) 1e-6)
(equal q2 (vlax-curve-getEndPoint en) 1e-6)))
(if ex (entdel ex))
(progn
(entdel en)
(setq en ex)))
(setq e1 (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 q1) (cons 8 la)))
e2 (entmakex (list (cons 0 "LINE") (cons 10 p2) (cons 11 q2) (cons 8 la))))
(initcommandversion)
(command "_.JOIN" e1 en e2 "")
))
(princ)
)

 

Thank you!

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

ВeekeeCZ
Consultant
Consultant
Accepted solution

Hi Vijay,

 

hmm, I see no mentioning of the author, no intent to learn anything, you don't even know what you want, no kudos given... Why we should 'help' you? Will 'help' you if I tell you that you need to use a loop, (while (getpoint "Next point") ...) would be probably the best choice... or you just want get a code from us?

 

Well, since is this my code, I'll do that, it's not much complicated... but some effort from your side would be welcomed. Next time?

 

Spoiler
(vl-load-com)

(defun c:cbline ( / en em ex el p1 q1 p2 q2 pe ps la ss)
  
  (if (and (setq en (car (entsel "\nSelect axis polyline: ")))
           (or (= "LWPOLYLINE" (cdr (assoc 0 (entget en))))
               (prompt "\nSelected entity si not a polyline."))
           (setq p1 (getpoint "\nSpecify first point: "))
           (setq p1 (trans p1 1 0))
           (setq q1 (vlax-curve-getClosestPointTo en p1))
           (setq la "test")
           (vl-cmdf "_.LAYER" "_New" la "_Color" 2 la "")
           )
    (while (setq p2 (getpoint "\nSpecify next point to connect with <done>: "))
      (if (and (setq p2 (trans p2 1 0))
               (setq q2 (vlax-curve-getClosestPointTo en p2))
               (setq ps (vlax-curve-getStartPoint en))
               (setq pe (vlax-curve-getEndPoint en))
               )
        (progn
          (setq em (entmakex (append (entget en)
                                     (list (cons 8 la)))))
          (setq el (entlast))
          (and (not (equal q1 pe 1e-6))
               (not (equal q1 ps 1e-6))
               (vl-cmdf "_.BREAK" em "_none" (trans q1 0 1) "_none" (trans q1 0 1))
               (not (equal el (entlast)))
               (setq ex (entlast))
               )
          (if (equal q2 (vlax-curve-getClosestPointTo em q2) 1e-6)
            (if ex (entdel ex))
            (progn
              (entdel em)
              (setq em ex)))
          (setq ex nil
                el (entlast))
          (and (not (equal q2 pe 1e-6))
               (not (equal q2 ps 1e-6))
               (vl-cmdf "_.BREAK" em "_none" (trans q2 0 1) "_none" (trans q2 0 1))
               (not (equal el (entlast)))
               (setq ex (entlast))
               )
          (if (and (or (equal q1 (vlax-curve-getStartPoint em) 1e-6)
                       (equal q1 (vlax-curve-getEndPoint em) 1e-6))
                   (or (equal q2 (vlax-curve-getStartPoint em) 1e-6)
                       (equal q2 (vlax-curve-getEndPoint em) 1e-6)))
            (if ex (entdel ex))
            (progn
              (entdel em)
              (setq em ex)))
          (setq ss (ssadd em))
          (if (not (equal p1 q1 1e-6))
            (ssadd (entmakex (list (cons 0 "LINE") (cons 10 p1) (cons 11 q1) (cons 8 la))) ss))
          (if (not (equal p2 q2 1e-6))
            (ssadd (entmakex (list (cons 0 "LINE") (cons 10 p2) (cons 11 q2) (cons 8 la))) ss))
          (initcommandversion)
          (command "_.JOIN" ss "")
          ))))
  (princ)
)

BTW It works reversed workflow than you want. Select a polyline, then a first point, then all other points are connected with the first one.

Message 3 of 9

Anonymous
Not applicable

Hi Beekee,

 

Thank you Beekee,

 

Do not think like that, I am a learner my self i am preparing some of lisp which is little one, in some conditions I am asking your help because i could not have that much of knowledge , you people have great knowledge on this ,so that's the reason i am taking your help.

 

Sorry for disturb. 

0 Likes
Message 4 of 9

john.uhden
Mentor
Mentor

You've created two separate topics which except for the title are both the same.  Your question doesn't seem to fit with your code, which turns out to be someone else's.  Could you please explain what your goal is?  Maybe you can post your own code for us to help you with.

John F. Uhden

0 Likes
Message 5 of 9

ВeekeeCZ
Consultant
Consultant

You're welcome!

Glad to hear that! By trying writing your own code you will learn much more. If you reach a dead end, we are here to help! No hard feelings, glad to help 🙂

 

@john.uhden

The OP's intention is not much clear, but from his example DWG attached his previous topic HERE, where you've participated as well, is the goal much more obvious. Unfortunately, the OP did not attached that this time.

Anyway, I've reported the second thread to the moderator to be removed.

0 Likes
Message 6 of 9

john.uhden
Mentor
Mentor
I looked at your screencast and I still don't get why he needs any
programming. Just draw the polylines on the right layer... Done. Then if
he wants to quantify the lengths, we use someone's "Total Length" program,
or make him one that quantifies the number of various patch cord lengths.
For example, a 6' length requires a 7' patch cord, etc. To my recollection
patch cords come in lengths of 3', 5', 7', 10', 15', 25', and 50'. I've
got to go buy a 25' one today for our new smart TV. I will not be drawing
the route in AutoCAD; I'm just estimating the distance conservatively.
Drilling a new hole in the floor is easier than punching down new inserts
and still having to buy two short patch cords.

John F. Uhden

0 Likes
Message 7 of 9

ВeekeeCZ
Consultant
Consultant

John, the OP's goal makes sense to me. But that's not much important - I just provided a solution that does make sense to the OP. And he's glad to have that.

 

What I can imagine is that we are building a PC net - just as an example. It's a centralized structure, each PC must be connected to center, to the server, by twisted-pair cable. So be it. Then you need your TotalLength routine. But drawing a polyline to each table, which of you can have a really big number, that is the issue to me.

 

I would leave this. 🙂

 

0 Likes
Message 8 of 9

john.uhden
Mentor
Mentor

That's when you have the cheapest employee do the drawing.

I once had a situation where the cheapest guy wasn't billing enough time (because of his lack of capabilities), but I had a project that was labor intensive.  So rather than my doing all the tedious work I wrote a program to extract the areas of varying width polylines, instructed the guy how to draw them, and got the job done cheap while at the same time boosting his performance ratio.  Sadly, he got laid off later anyway, but the job was very profitable.

John F. Uhden

0 Likes
Message 9 of 9

john.uhden
Mentor
Mentor
You're right. It's left. 🙂

John F. Uhden

0 Likes