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.

virgal

I use design cad to create drawings for a laser cutter.  V18 express.
The problem that I have been running into is knowing if I have multiple lines between 2 given points.  (Lines on top of each other.)  if I do not remove them the laser will pass over the same line for each that is stacked there.  Is there any routine that can id multiple lines.

Thanks Alan

JJG

In "Tools", you will find "2D Lines Cleanup", which would be expected to do what you need ;

In reality, this tool just only does "to group" lines together, a bit like "Edit/ Selection Edit/ Combine Lines", and can not guarantee that you would not have multiple lines one above the other.

Note too, that to undo "2D Lines Cleanup", the traditional command "undo" (Ctrl Z) does not work : you must re-select the lines for which this command was used [eg with "Shift P"("Edit/ Selection Edit/ Select previous"], then use "Ctrl Alt 6" ("Edit/ Selection Edit/ Break Lines"), to break (= "to explose") the lines into simple vectors.

virgal

Thank you for your reply
Tried your suggestion.  It seems to work if you select the individual line in question.
Problem is I don't know which line or lines may be multiple.  I tried doing a select all and clean up.  did not work.  Did a select all, recursive group explode and clean up .  did not work.  More suggestions please.

A bit more info.  When I complete a DC drawing, I ship it off to my laser guy.  He takes it and does an dxf export, and then runs it through another program (unidentified and I believe proprietary ) that he can use to do a final massage on the drawing.  With that program he can search for multiple lines and they are identified with options to fix.  I know it sounds like the solution is to use his program before cutting, but I would prefer to know of the problem in design cad and be able to fix it before I release the drawings because my source drawings still have the problem.
Alan

Bob P

Try this.  I don't remember who wrote this, but it's a modification of my original DOS macro.  Make sure that you are able to edit all layers before you start.

'opt.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.
window 2,2
print "Please Wait . . ."
'
' Turn off Error Reporting
   Sys(0) = 0
' Loop through all the objects in the drawing
   for a = 1 to Sys(9)
   ' Select the first object
      Entity a
      ' Get the point values for this object
      for b = 1 to Sys(1)
         pointval OneX1 OneY1 OneZ1 1
         pointval OneX2 OneY2 OneZ2 2
      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
            for e = 1 to Sys(1)
               PointVal TwoX1 TwoY1 TwoZ1 1
               PointVal TwoX2 TwoY2 TwoZ2 2
            next e
            ' Compare Point Location of the 2 Items
               ' Check for first point match
               if OneX1 = TwoX1 AND OneY1 = TwoY1 AND OneZ1 = TwoZ1 then
                  ' Check for second point match
                  if OneX2 = TwoX2 AND OneY2 = TwoY2 AND OneZ2 = TwoZ2 then
                     ' Select the duplicate object
                        >PointSelect
                        {
                        <Type 1
                        <Pointxyz [TwoX2, TwoY2, TwoZ2]
                        }
                        f = f + 1
                  endif
               endif
      next c
   next a
   ' Delete it
   >SelectDelete
   {
   }
>Regenerate
{
}
WClose
Precision 0
f$ = f
Message "Finished !! " + f$ + " duplicate objects removed."
End

virgal

Bob
Although a long time user of dc I never worked with macros. Need instructions on how to implement.
Thanks
Alan

Rob S

#5
All you do is clipboard-copy the text above, paste into notepad, and save it in your macros folder, as a text file named something like "DuplicateRemover.d3m"

Then with your file open, from the menu "tools, macro execute" and pick the file from the list.

This macro does what it says, but it has a couple of issues, so use with caution:

1) It only checks the first two points of each object, so it will remove any object having its first two points co-incident with any second object, so if you have multi-point objects with the first two points duplicated, one of them will be removed.

2) It checks any object against any subsequently drawn object of the same or different type, so if you have a vector co-incident with the first two points of some text, one of them will be removed.  

3) The counts don't seem to be accurate, not sure why yet.

If your drawing consists entirely of two-point vectors, it will work fine.  

It could be refined to eliminate those problems, and I don't doubt one of the GURU's here will rise to the challenge, meanwhile, you might be able to select all the vectors in your drawing, place them on a new layer, freeze the rest, and it would be safer.

Definitely suggest testing on a duplicate file first!!!

User since forever

virgal

thank you  Bob

will try this evening.
for all that may be interested, this is what i do with DC. www.thegalline.com

thanks again
alan

JJG

#7
Alan, I see we have somewhere the same center of interest !
http://www.letrainmagique.com/Realisations_laiton.htm

But from my side, I do not use laser cutting (too expensive, and I can not do myself) : I cut myself all by chemical etching.
this way, I have no problem with overlap lines in DesignCAD, because then, I prints a black mask of the piece I want to do, then I expose it with ultra violet, and after, I burn the piece in a bath of ferric chloride or ammonium persulfate.

All that to say this is another way to circumvent the problem of overlapping lines !!!  ;)

virgal

Rob
No luck. I have attached a part of the drawing that I have been testing.

JJG
Please email me directly  virgal at verizon.net

Bob P

The macro won't work on lines with more than one segment.

I tried breaking the lines but the macro fails to remove all the duplicates (still leaving four out of the seven lines), even after running the macro multiple times.  So I'm stuck.  :'(

Lar

#10
virgal, if all your drawings have as few lines as your example you can (with Point Select Mode so the points show) Shift+Click on the entities one at a time until everything is visually selected. Then turn off point sel mode and Shift+Drag-Select everything so the selection set gets inverted. If anything is left selected you should then move them off to the side somewhere. Don't delete them until you are certain you selected everything necessary the first time.

I have a macro that can get rid of overlapping lines that sit either entirely over or partly within other lines. It doesn't yet work on lines that start beyond each other and sit only partly over each other and it would break lines into single segments. It has removed upwards of 20,000 lines out of a 30 or 40,000 line file (it actually tells you how many lines were removed and how many remain). If you have files with too many lines to do manually or too many small files you can send me a private forum message and we can discuss it.

Lar

Rob S

#11
I did some work on this macro as follows

1) Made it select the entity itself by number, instead of point-select, which caused it to keep selecting the same item in a multiple-duplicate situation

2) Made it work on lines only, so it is much faster on large files, if you want it to do other entity types, you can comment out the if statement in line 21

3) Made it display what it is going to delete, for confirmation.

4) Fixed the counter.

5) Put a progress indicator in the status bar for really large files!

Remaining issues

1) It still only checks for the first two points of the lines to be equal,

2) for some weird reason it sometimes selects a dimension

3) if the co-incident lines were drawn in opposite directions it won't find them

Try it as below:



'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)

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
              ' Check for first point match
              if OneX1 = TwoX1 AND OneY1 = TwoY1 AND OneZ1 = TwoZ1 then
                 ' Check for second point match
                 if OneX2 = TwoX2 AND OneY2 = TwoY2 AND OneZ2 = TwoZ2 then
                    ' Select the duplicate object
                       getattr d, type, select
                       if select = 0 then
                       select = 1
                       putattr d, type, select
                       f = f + 1
                       endif
                   end if
 
                 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
User since forever

magic

Hi virgal,

This seems to work:

Go Edit > Selection Filter, choose Entity Type > Line Add ---->, click Add to Selection and Close.

Go Edit > Selection Edit > Break Line (You do this, because otherwise you end up with little bits missing, and most CNC cutter programs only accept 2 point lines anyway).

Go Tools > 2D Lines Clean Up and remove the check mark at Combine Connected Lines.

Best of luck!
It's a kind of magic!




magic

Hi Rob,

You just managed to place your macro, while I was doing my little bit, but I just tested it, and it works great.
It's a kind of magic!




Rob S

#14
Magic, if you look at your cleaned up file above, you will see that the "2D line cleanup" didn't really work - the 4 point line which had 7 duplications, now is a single entity with 28 points!!!

I have developed a solution for lines drawn in opposite directions, still only checks first two points.

It would be quite simple to make it work only on two-point lines (broken into segments) , if that is desired.

To check for identical multi-segment lines would be more difficult, but I have an idea how to do it if anyone wants it.

To check for combined overlaid lines like in the file above I have no idea how I would do that.





'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)

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 ((OneX1 = TwoX1 AND OneY1 = TwoY1 AND OneZ1 = TwoZ1) and (OneX2 = TwoX2 AND OneY2 = TwoY2 AND OneZ2 = TwoZ2)) or ((OneX1 = TwoX2 AND OneY1 = TwoY2 AND OneZ1 = TwoZ2) and (OneX2 = TwoX1 AND OneY2 = TwoY1 AND OneZ2 = TwoZ1)) 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

User since forever