Polyline/rev clouds and dxf codes

Polyline/rev clouds and dxf codes

CSM_MAI
Advocate Advocate
1,821 Views
16 Replies
Message 1 of 17

Polyline/rev clouds and dxf codes

CSM_MAI
Advocate
Advocate
Is there a way to destenguish between a polyline and a revcloud polyline using dxf codes within lisp? I need to select all polyline revclouds on a specific layer but not regular polylines. Any info would be appreciated. Thanks.
0 Likes
1,822 Views
16 Replies
Replies (16)
Message 2 of 17

Kent1Cooper
Consultant
Consultant

@CSM_MAI wrote:
Is there a way to destenguish between a polyline and a revcloud polyline using dxf codes within lisp? I need to select all polyline revclouds on a specific layer but not regular polylines. Any info would be appreciated. Thanks.

Assuming this hasn't changed since I wrote the MakeMore.lsp routine involving this question, long ago, a Revcloud that has not been altered  [i.e. Trimmed, Broken, Stretched, grip-edited any arc segments to a different shape] has all bulge factors of its arc segments the same, even of different-length segments.

 

The following excerpts from MakeMore use 'data' as a variable containing the entity data list of a Polyline.  The 'cl' variable comes from earlier in the larger routine, being T if the Polyline is closed or nil if it's open.

 

The eq42 function is to test whether all bulge factors are equal to a given value:

 

(defun eq42 (val / pdata); find whether *all* bulge factors [(assoc 42) entries] have specified value
  (setq pdata data)
  (while (equal (cdr (assoc 42 pdata)) val 1e-6); can be + or -
    (setq pdata (cdr (member (assoc 42 pdata) pdata))); remainder after this 42 entry
  ); while
  (not (assoc 42 pdata)); returns T if they were all equal [none left]
); defun - eq42

 

This (and) function tests whether a Polyline could  have been drawn with the Revcloud commmand [it would be a pretty remarkable coincidence if it were drawn otherwise with only arc segments of exactly the right bulge factor]:

 

(and
  (assoc 43 data); global width [this was from before the calligraphic option existed]
  (or
    (and
      cl ; it's closed
      (or (eq42 0.520567) (eq42 -0.520567)); all Revcloud-type arc segments, bulging same direction
    ); and
    (and
      (not cl) it's open
      (setq data (reverse (cddr (reverse data))))
        ; removes last (42) entry, which is 0 for open Revclouds.  Then:
      (or (eq42 0.520567) (eq42 -0.520567)); all Revcloud-type remaining
    ); and
  ); or
); and

 

But  if you Break/Trim/Stretch/grip-edit/etc. a Revcloud, at least some bulge factor(s) will change, so the above will not recognize it as one.

 

To find all of what you're looking for, you would have to first find all Polylines on the Layer you want, then step through the selection set and apply the test to each one, (ssdel)-ing those that don't pass to remove them from the selection set.

Kent Cooper, AIA
0 Likes
Message 3 of 17

DannyNL
Advisor
Advisor

I know this will probably not be 100% foolproof and there wil be situations when it will select more (if a 'normal' polyline only exists of arcs and these all have a bulge factor larger than arcs in a revision cloud) or less (when you have modified an existing revision cloud, so one or more arcs have a bulge factor less than standard) than what you need. But it probably will be sufficient in 99% of the cases.

 

(defun c:RevCloudSelect (/ RCS_Pick RCS_Selection)
   (princ "\nSelect existing revision cloud")
   (setq RCS_Pick (ssget ":S" '((0 . "LWPOLYLINE") (-4 . ">=") (42 . 0.520567))))
   (if
      RCS_Pick
      (progn
         (setq RCS_Selection (ssget "X" (list (cons 0 "LWPOLYLINE") (cons 8 (cdr (assoc 8 (entget (ssname RCS_Pick 0))))) (cons -4  ">=") (cons 42 0.520567))))
         (if
            RCS_Selection
            (sssetfirst nil RCS_Selection)
         )
      )
      (princ "\nNo revision cloud selected")
   )
   (princ)
)

 

0 Likes
Message 4 of 17

john.uhden
Mentor
Mentor

That's pretty clever, Danny.

Plus, I would presume that the signs of all bulges are the same (though not necessarily always positive or always negative) and that the polyline is closed, right?  Basically it would be the same as my scalloped tree line, though that is not always closed.

John F. Uhden

0 Likes
Message 5 of 17

DannyNL
Advisor
Advisor

Thanks John.

 

I'm assuming a positive bulge factor, but it wouldn't be difficult to add another conditions to also select revision clouds that have been inverted.

 

Furthermore the polyline doesn't necessarily need to be closed. In fact I have tested with a revision cloud that has been trimmed or opened with BREAK and in both cases the revision cloud still matched the conditions for selection.

0 Likes
Message 6 of 17

john.uhden
Mentor
Mentor

I wasn't thinking about an "inverted" revcloud.  I think the bulges get their sign from the direction the user draws the revcloud.  CCW=positive and CW=negative.

John F. Uhden

0 Likes
Message 7 of 17

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

....  I think the bulges get their sign from the direction the user draws the revcloud.  CCW=positive and CW=negative.


They are in relation to the combination of drawn direction and bulge direction.  For one drawn in the CCW direction with bulges outward, they will be positive, but if you opt to Reverse the bulge direction, they will be negative though the drawn direction of the cloud remains the same.  Or if you Mirror one, the bulge factors will all switch sign.

 

In older versions that don't have the Reverse-bulge option in the base command, it's there within the convert-an-Object option [unless the version is old enough not to have that, either].

Kent Cooper, AIA
0 Likes
Message 8 of 17

CSM_MAI
Advocate
Advocate

Thank you for all the information. I did manage to narrow down my selection set of the polylines by the bulge factor. Like you stated before, If the revcloud has been broken, the bulge factor turns to 0. I will have to rely on User discretion when selecting the entities in the drawing, if I choose to go this route. I was able to narrow it down by the layer and a 0.0 bulge factor and managed to get a majority of the clouds. 

 

(0 . "polyline,lwpolyline")
(8 . "revlayer")
(42 . 0.0)

0 Likes
Message 9 of 17

DannyNL
Advisor
Advisor

As far as I can tell the bulge factor will not be 0.0 with a broken revision cloud.

A revision cloud drawn with the command REVCLOUD and broken at any random point will still have the bulge factor. In what kind of situation will you get a bulge factor of 0.0?

0 Likes
Message 10 of 17

john.uhden
Mentor
Mentor

I think a revcloud would have to have at least one (1) segment straightened (or of the opposite bulge sign from the rest) in order for it to not be an automatic candidate.

Of course we are dealing sort of like paleontologists here, deriving the definition of something created years ago.  It's sorta like the BC episode where he and his buddy find some strange animal with a long snout.  They ask each other what they should name it.  One of them says "Well, it seems to like eating ants."  "Well, then, that's obvious," says BC.  "It must be an eat anter."

John F. Uhden

0 Likes
Message 11 of 17

Kent1Cooper
Consultant
Consultant

@DannyNL wrote:

As far as I can tell the bulge factor will not be 0.0 with a broken revision cloud.

A revision cloud drawn with the command REVCLOUD and broken at any random point will still have the bulge factor. In what kind of situation will you get a bulge factor of 0.0?


Again, this was the case back when I wrote MakeMore.lsp, but the bulge factor associated with the last vertex was 0 [I'm away from all access to AutoCAD this week, so I can't test whether that's still the case].  That's not the bulge factor of any segment, so there are no line segments in the Polyline, but even the vertex at the end gets an associated bulge factor entry, and in my testing at the time that was always 0 when the Polyline was broken/trimmed.  On one that was broken at a vertex, the preceding segment would still have the standard bulge factor, so I wanted such a Revcloud to be recognized as one, but since the test is for all bulge factors to be the same value, I had to eliminate the one that's zero at the end [see Post 2].

Kent Cooper, AIA
0 Likes
Message 12 of 17

CSM_MAI
Advocate
Advocate

I cannot recreate a scenario where the revcloud has 0.0 for the buldge factor, but upon searching the drawing, I find several polyline revclouds that have 0.0 as their bulge factor. Could it be that these entities were created in a much older version of AutoCAD? I wouldn't think that has anything to do with it. I have drawn a revcloud using the revcloud command, drawn a polyline and then converted it to a revcloud, and also made a spline and converted it to a revcloud. All of which have a bulge factor even after some sort of manipulation. 

0 Likes
Message 13 of 17

john.uhden
Mentor
Mentor
It could be that either...

a) Someone had joined revclouds to a straight segment, or
b) Someone had used PEDIT to straighten a segment, or
c) Someone grip edited the segment and actually made it straight, or
d) Someone had used my BULGE command to straighten a segment, or
e) Foreign hackers have taken over your AutoCAD and are conducting mind
control tests.
By now you have set ISAVEPERCENT to 100 and SAVETIME to 9999.
You are also rotating your modelspace instead of DVIEW; Twisting.
To recover you must find and return the crystal skull to Akator. Yes,
that includes
driving the amphibious car over three waterfalls.

<>
Virus-free.
www.avast.com
<>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

John F. Uhden

0 Likes
Message 14 of 17

Kent1Cooper
Consultant
Consultant

@CSM_MAI wrote:

I cannot recreate a scenario where the revcloud has 0.0 for the buldge factor, but upon searching the drawing, I find several polyline revclouds that have 0.0 as their bulge factor. Could it be that these entities were created in a much older version of AutoCAD? I wouldn't think that has anything to do with it. I have drawn a revcloud using the revcloud command, drawn a polyline and then converted it to a revcloud, and also made a spline and converted it to a revcloud. All of which have a bulge factor even after some sort of manipulation. 


Have you tried making a Revcloud that is not closed?  End the command with Enter without carrying around to closing the cloud.  Then, in Acad2016 [not so very old] that I have here, this is near the end of the entity data list [that was also always the one with 0 bulge factor back when I wrote MakeMore.lsp]:

 

... (10 32.0631 -6.55578) (40 . 0.0) (41 . 0.0) (42 . 0.0) ...

 

That (10 ...) entry is the final vertex location, and the bulge factor associated with it is zero.

Kent Cooper, AIA
0 Likes
Message 15 of 17

DannyNL
Advisor
Advisor

Yes, you 're right. I wrote my routine in 2017 and the REVCLOUD command in this version only creates LWPOLYLINES with uniform bulge factors.

 

However, after testing in 2014 I've found it's a pretty mess with bulge factors as a positive or negative number, bulge factors at 0.0 (not only at end or beginning but sometimes also in between arc segments as separate vertices) and bulge factors with different values if the revcloud has been broken.

In total the number of vertices with a bulge factor smaller than the bulge factor of an arc segment can even be more then 50% of all the vertices.

 

I've rewritten my code to take this into account.

As a consequence I'm not able to filter the selection anymore at SSGET level, but need to step through all LWPOLYLINES one by one and determine if it is a revcloud or not. A LWPOLYLINE is considered to be a revcloud if more then 47.5% (the set threshold based on testing several revclouds) of the vertices has a bulge factor larger than 0.520567.

 

This also means that if you create a LWPOLYLINE manually with more ARC segments than LINE segments and the bulge factor of the ARC segments is larger or equal to 0.520567, it might be wrongly identified as a revcloud.

 

(defun c:RevCloudSelect (/ RCS_Pick RCS_Selection RCS_Threshold RCS_Count RCS_Entity RCS_ValueList RCS_Return)
   (princ "\nSelect existing revision cloud")
   (setq RCS_Pick (ssget ":S" '((0 . "LWPOLYLINE"))))
   (if
      RCS_Pick
      (progn
         (setq RCS_Selection (ssget "X" (list (cons 0 "LWPOLYLINE") (cons 8 (cdr (assoc 8 (entget (ssname RCS_Pick 0))))))))
         (if
            RCS_Selection
            (progn
               (setq RCS_Return (ssadd))
               (setq RCS_Threshold 0.475)
               (setq RCS_Count 0)
               (repeat (sslength RCS_Selection)
                  (setq RCS_Entity (ssname RCS_Selection RCS_Count))
                  (setq RCS_ValueList (mapcar 'cdr  (vl-remove-if '(lambda (RCS_Item)(/= (car RCS_Item) 42)) (entget RCS_Entity))))
                  (if
                     (>= (/ (length (vl-remove-if '(lambda (RCS_Item)(< (abs RCS_Item) 0.520567)) RCS_ValueList)) (float (length RCS_ValueList))) RCS_Threshold)
                     (ssadd RCS_Entity RCS_Return)
                  )
                  (setq RCS_Count (1+ RCS_Count))
               )
               (if
                  (> (sslength RCS_Return) 0)
                  (sssetfirst nil RCS_Return)
               )
            )
         )
      )
      (princ "\nNo revision cloud selected")
   )
   (princ)
)
0 Likes
Message 16 of 17

john.uhden
Mentor
Mentor

Ahah!  So my scalloped tree line is actually a revcloud.  My old screwdiver is really a chisel too.

John F. Uhden

0 Likes
Message 17 of 17

DannyNL
Advisor
Advisor

Yep, I guess it is Smiley Happy

It's one or the other, you can't have both as long a revcloud is a lwpolyline and you have no other means to identify it except a bulge factor.

 

But just change the threshold to a higher value and see what works best for you.

0 Likes