DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

checking for multiple lines in a drawing

Started by virgal, January 15, 2011, 05:57:34 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

magic

Hi Rob,

Sorry, I don't see 28 points using point select mode, but they are there in the infobox. Why is that?
It's a kind of magic!




JJG

#16
for all,

I also want to remember to you, that in "Feature Requests" I have already discussed this problem of overlapping lines :
http://forum.designcad.com/index.php?topic=2408.0

in this case, Virgal uses his file to be executed by a machine = the problem is the number of passages in the same place.


Myself, I pointed out another problem with superposed the lines = this one of representation, when the linesytle is other than "continuous" : several superposed lines look like as it was "continuous" linestyle, and distorts the reading of the drawing .

this "detail" sould be finally taken seriously in hand by the developer of DesignCAD.
In other Cad-SOFTWARE, large caliber, such as Solidworks or other, there is no problem with this !

and in the topic I discussed in "Feature Requests", I gave a track, inspired by the representation of hatching, which even if they are superposed, do not change their appearance as long as they are of the same scale and style!

JJG

Quote from: magic on January 15, 2011, 10:13:42 PM
Hi Rob,

Sorry, I don't see 28 points using point select mode, but they are there in the infobox. Why is that?
It's just because they are overlapping one above the others !!!

Rob S

#18

You can edit the point co-ordinates in the info box to pull the whole thing apart again too!!!

If you select these overlapping lines as-is, break them, run the macro, and then the "2D cleanup", the result is single re-combined lines with no overlap.  See result below.

It seems you need to click on the drawing window before running the macro, or regen after the break command for the macro to find all 48 duplicates!!!

On some occasions the macro above fails to find some duplicate segments, I wonder if it has to do with the equalness of the last digit of the 16 decimal place point value??
User since forever

Bob P

I added point tolerance to the last macro, but I keep getting an error on the long "if" line (#48)

'DeleteDuplicateLines.d3m

' This simple macro removes duplicate lines which lie on top of each other in the drawing
' This macro could take a LONG time to complete on a complicated drawing.

' Turn off Error Reporting
   Sys(0) = 0
' Loop through all the objects in the drawing
   for a = 1 to Sys(9)

input "Enter the tolerance for matching points: ", tol

F$ = a/Sys(9)*100

print "Working, Please Wait . . .", f$ , " %"


' Select the first object
    Entity a

' determine if entity a is a line, if not, skip to next entity
    getattr a, type
    if type <> 1 then next a

' Get the point values for this object

      if Sys(1) > 1 then
         pointval OneX1 OneY1 OneZ1 1
         pointval OneX2 OneY2 OneZ2 2
         end if

      'next b
      ' Loop through the rest of the objects

      c = a + 1
      for d = C to Sys(9)

         ' Select the next object in the drawing
            Entity d
            ' Get the point values for that object
            if Sys(1) > 1 then
               PointVal TwoX1 TwoY1 TwoZ1 1
               PointVal TwoX2 TwoY2 TwoZ2 2
           
            ' Compare Point Location of the 2 Items

               if ((abs(OneX1-TwoX1)<tol AND abs(OneY1-TwoY1)<tol AND abs(OneZ1-TwoZ1)<tol) and (abs(OneX2-TwoX2)<tol AND abs(OneY2-TwoY2)<tol AND abs(OneZ2-TwoZ2)<tol)) or ((abs(OneX1-TwoX2)<tol AND abs(OneY1-TwoY2)<tol AND abs(OneZ1-TwoZ2)<tol) and (abs(OneX2-TwoX1)<tol AND abs(OneY2-TwoY1)<tol AND abs(OneZ2-TwoZ1)<tol)) then
                     ' Select the duplicate object
                        getattr d, type, select
                        if select = 0 then
                        select = 1
                        putattr d, type, select
                        f = f + 1
                        endif
                 
   
                  endif

               endif
      next c
'end if
   next a


>Regenerate
{
}

prompt$ = "Press 1 to delete = ", sys(80),  "lines,  any other key to keep"

print "Number of entities to be deleted = ", sys(80)
input , [prompt$], ts

if ts <> 1 then end

  ' Delete it
   >SelectDelete
   {
   }

>Regenerate
{
}
WClose
Precision 0
f$ = f
Message "Finished !! " + f$ + " duplicate objects removed."
End

Rob S

#20
The long line needs to be on one single line of text in the macro, OK it is, I'll see if I can figure it out....

I think it might be this

Quote"A line of code may not exceed 255 characters in length (including white space). "
User since forever

Rob S


OK, fixed that, using two separate if statements. Would have posted sooner except for we had a power outage here.

Now why does it only work for 4 decimal places or less?  You still need to click on the drawing space after the break lines command for it to work - don't know why.

Next trick would be to have it only check each line against other lines in the same area of the drawing.....



' DeleteDuplicateLines.d3m
' This ?simple? macro removes duplicate lines the first two points of which lie on top of each other in the drawing
' This macro could take a LONG time to complete on a complicated drawing.

' Turn off Error Reporting
   Sys(0) = 0

input "Enter the tolerance for matching points - .001 usually works: ", tol

' Loop through all the objects in the drawing, populate progress indicator in status line
   for a = 1 to Sys(9)
   F$ = a/Sys(9)*100
   print "Working, Please Wait . . .", f$ , " % done, - ", sys(80), "duplicates found."


' Select the first object
    Entity a

' Determine if entity a is a line, if not, skip to next entity
    getattr a, type
    if type <> 1 then next a

' Get the point values for this object

      if Sys(1) > 1 then
         pointval OneX1 OneY1 OneZ1 1
         pointval OneX2 OneY2 OneZ2 2
         end if

' Loop through the rest of the objects

      c = a + 1
      for d = C to Sys(9)
            Entity d

' Get the point values for that object
            if Sys(1) > 1 then
               PointVal TwoX1 TwoY1 TwoZ1 1
               PointVal TwoX2 TwoY2 TwoZ2 2
           
' Compare Point Locations of the 2 Items
               if ((abs(OneX1-TwoX1)<tol AND abs(OneY1-TwoY1)<tol AND abs(OneZ1-TwoZ1)<tol) and (abs(OneX2-TwoX2)<tol AND abs(OneY2-TwoY2)<tol AND abs(OneZ2-TwoZ2)<tol)) then dup = 1
               if ((abs(OneX1-TwoX2)<tol AND abs(OneY1-TwoY2)<tol AND abs(OneZ1-TwoZ2)<tol) and (abs(OneX2-TwoX1)<tol AND abs(OneY2-TwoY1)<tol AND abs(OneZ2-TwoZ1)<tol)) then dup = 1
               If dup = 1 then

' Select the duplicate object
                  getattr d, type, select
                  if select = 0 then
                        select = 1
                        putattr d, type, select
                        f = f + 1
                        endif
                  dup = 0
                  endif
               endif
      next c
  next a


>Regenerate
{
}

prompt$ = "Press 1 to delete = ", sys(80),  "lines,  any other key to keep"

print "Number of entities to be deleted = ", sys(80)
input , [prompt$], ts

if ts <> 1 then end

  ' Delete it
   >SelectDelete
   {
   }

>Regenerate
{
}
WClose
Precision 0
f$ = f
Message "Finished !! " + f$ + " duplicate objects removed."
End
User since forever

Bob P

I'm lazy.  I replaced

input "Enter the tolerance for matching points - .001 usually works: ", tol

with

tol=0
input "Enter the tolerance for matching points - .001 usually works: ", tol
if tol=0 then tol=.001

so you can just hit enter instead of entering a tolerance.  ;D


Rob S

#23
Cool!  Except for me I had to change the "iif" to just "if"

Now we could change the Input text to:

  "Fill in the tolerance for matching points - or press ENTER to accept default .001 "

In the following version, I also fixed the message box at the end so you don't have to type anything.



' DeleteDuplicateLines.d3m
' This simple macro removes duplicate lines the first two points of which lie on top of each other in the drawing
' This macro could take a LONG time to complete on a complicated drawing.

' Turn off Error Reporting
   Sys(0) = 0

Input "Fill in tolerance for matching points - or press ENTER to accept default .001 ", tol
if tol=0 then tol=.001

' Loop through all the objects in the drawing, populate progress indicator in status line
   for a = 1 to Sys(9)
   F$ = a/Sys(9)*100
   print "Working, Please Wait . . .", f$ , " % done, - ", sys(80), "duplicates found."


' Select the first object
    Entity a

' Determine if entity a is a line, if not, skip to next entity
    getattr a, type
    if type <> 1 then next a

' Get the point values for this object

      if Sys(1) > 1 then
         pointval OneX1 OneY1 OneZ1 1
         pointval OneX2 OneY2 OneZ2 2
         end if

' Loop through the rest of the objects

      c = a + 1
      for d = C to Sys(9)
            Entity d

' Get the point values for that object
            if Sys(1) > 1 then
               PointVal TwoX1 TwoY1 TwoZ1 1
               PointVal TwoX2 TwoY2 TwoZ2 2
           
' Compare Point Locations of the 2 Items
               if ((abs(OneX1-TwoX1)<tol AND abs(OneY1-TwoY1)<tol AND abs(OneZ1-TwoZ1)<tol) and (abs(OneX2-TwoX2)<tol AND abs(OneY2-TwoY2)<tol AND abs(OneZ2-TwoZ2)<tol)) then dup = 1
               if ((abs(OneX1-TwoX2)<tol AND abs(OneY1-TwoY2)<tol AND abs(OneZ1-TwoZ2)<tol) and (abs(OneX2-TwoX1)<tol AND abs(OneY2-TwoY1)<tol AND abs(OneZ2-TwoZ1)<tol)) then dup = 1
               If dup = 1 then

' Select the duplicate object
                  getattr d, type, select
                  if select = 0 then
                        select = 1
                        putattr d, type, select
                        f = f + 1
                        endif
                  dup = 0
                  endif
               endif
      next c
  next a


>Regenerate
{
}

Precision 0

print "Completed,", sys(80),  "duplicate entities found. "

Sys(1027) = 4 'Yes/No MessageBox style


Message "Press Enter to delete ", sys(80),  " lines,   N to keep"

If Sys(1028) = 6 Then

  ' Delete them
   >SelectDelete
   {
   }

>Regenerate
{
}
WClose

f$ = f
Sys(1027) = 0
Message "Finished !! " + f$ + " duplicate lines removed."

end if
End

User since forever

virgal

thank you very much

this version seems to work for me.

again thanks

alan