WTF? (Why The Failure?)

WTF? (Why The Failure?)

john.uhden
Mentor Mentor
1,052 Views
7 Replies
Message 1 of 8

WTF? (Why The Failure?)

john.uhden
Mentor
Mentor

Attached is GetQuads.lsp previously submitted in response a request for locating quadrant points on selected polylines.  I've never experienced this, but there are two (2) annoying things...

 

1.  It does not repeat after the first object in the selection set.

2.  Running it a second time causes an elockviolation (I think because of using entmakex).

 

I have only vanilla 2002 installed, and my motherboard is going, but I would love to know what I am doing wrong or what else the cause is.

 

It is supposed to draw lines on layer "QUADS" from the center of each bulged polyline segment to any quadrants (NESW) found for that segment.

Please try it out and let me know what happens and what your ACAD version is.  Anyone else running 2002?

 

John F. Uhden

0 Likes
Accepted solutions (1)
1,053 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant

Not sure what it this line good for.

 

(if (> Param End)(setq Param 0) 1)

With this line commented, it looks like it works. (2015)

0 Likes
Message 3 of 8

john.uhden
Mentor
Mentor
Well I thought I needed that line in the case of a closed polyline. I remarked it out and am still encountering the same repeat and elockviolation symptoms. Maybe 2002 is the problem?

John F. Uhden

0 Likes
Message 4 of 8

dbroad
Mentor
Mentor
Accepted solution

With 

(if (> Param End)(setq Param 0) 1)

active, an infinite loop occurs even for one open spiral polyline selected. 

 

With it commented out, it works.  elock could be less of an issue in recent versions.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 5 of 8

john.uhden
Mentor
Mentor
Thanks for chiming in, Doug. What you said is correct. Nevertheless, my GetQuads2.lsp that I posted back to Dennis in his "...quadrants" thread can still cause an elockviolation. It's probably just all about me. I always get so confused with zero indexing.

Ya know I'm participating these days to spark my performance for my pool liner company. I've been way too lazy since my forced retirement (and aortic aneurism) that I figured you guys would help to wake up my brain. I think it's working.

John F. Uhden

0 Likes
Message 6 of 8

dbroad
Mentor
Mentor

Sorry about your aneurism. Hope doctors can repair it.  Sounds like you need to start a consulting business now that you're retired.

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 7 of 8

Kent1Cooper
Consultant
Consultant

Though it seems a lot more work this way than with Osnapping for centers, still, a few comments....

 

For avoiding endless loops and to eliminate confusion about indexing and the difference between closed and open Polylines:

 

You want to check for the bulge factor at the parameter at the beginning of every segment.  The last one of those is one less than the end parameter, whether the Polyline is open or closed.  I would be inclined to skip the comparison of the Parameter value to the End value in that (while) loop [also thereby eliminating the need for the End variable], and just tell it explicitly how many times to do it all, since you can determine the number of iterations needed, as you do with stepping through the selection set with a (repeat).  I'd replace this much:

 

        (setq Param 0 End (vlax-curve-getendparam Obj))
        (while (<= Param End)
          (and
            (princ (strcat "\nParam=" (itoa Param)))
            (setq P1 (vlax-curve-getpointatparam Obj Param))
            (setq Bulge (vla-getbulge Obj Param))
            (setq Param (1+ Param))
            (if (> Param End)(setq Param 0) 1)

            (not (zerop Bulge))
            (setq P2 (vlax-curve-getpointatparam Obj Param))

 

with something like this [which works backwards from the end]:

 

        (repeat (1- (setq Param (fix (vlax-curve-getendparam Obj))))
          (and
            (setq P2 (vlax-curve-getpointatparam Obj Param)); moved earlier, before stepping Param value down

            (princ (strcat "\nParam=" (itoa (setq Param (1- Param))))); previous Parameter to use in following 2 variables
            (setq P1 (vlax-curve-getpointatparam Obj Param))
            (setq Bulge (vla-getbulge Obj Param))

            (not (zerop Bulge))

 

 

Another thought -- here's a more concise way to define the (SignOf) function, returning the 1.0 or -1.0 value directly without the need for a test and different returns depending on the test result:

 

    (defun SignOf (#)
      (/ # (abs #))
    )

Kent Cooper, AIA
0 Likes
Message 8 of 8

john.uhden
Mentor
Mentor
The aneurism was only temporary, caused by high blood pressure. I tried consulting for 10 years from 1993 to 2003. I was lousy at marketing and got stiffed a lot. My claim to fame was being an expert with Land Desktop, but these days it's all about Civil 3D with which i am not good enough.

John F. Uhden

0 Likes