Author Topic: Removing double lines  (Read 107 times)

gavoss

  • Newbie
  • *
  • Posts: 4
Removing double lines
« on: February 27, 2019, 10:08:36 AM »
Is there a way to remove double lines in DesignCAD?  I'm referring to a line upon another line which obviously can't be seen.

Dr PR

  • Hero Member
  • *****
  • Posts: 5648
Re: Removing double lines
« Reply #1 on: February 27, 2019, 12:29:36 PM »
 DT, the former Forum administrator and long-time DesignCAD programmer, posted a macro to clean up overlapping lines. It is somewhere here on the Forum. Maybe someone else knows where it is. I can't find it on my system.

Here are three macros that will clean up some of the unwanted line segments. Open them in the Windows Notepad and text at the top will explain what they do.

Phil
DesignCAD user since 1987

Dr PR

  • Hero Member
  • *****
  • Posts: 5648
Re: Removing double lines
« Reply #2 on: February 27, 2019, 12:49:57 PM »
Here is a discussion of this problem:

http://forum.designcadcommunity.com/index.php?topic=3369.msg18112#msg18112

Here is a macro Rob S posted for removing duplicate lines:

' 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

Last Edit: January 17, 2011, 12:20:11 PM by Rob S
« Last Edit: February 27, 2019, 01:22:44 PM by Dr PR »
DesignCAD user since 1987

Dr PR

  • Hero Member
  • *****
  • Posts: 5648
Re: Removing double lines
« Reply #3 on: February 27, 2019, 01:05:48 PM »
Here is Bob P's macro (from the same discussion) for removing multiple lines:

'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
DesignCAD user since 1987

Dr PR

  • Hero Member
  • *****
  • Posts: 5648
Re: Removing double lines
« Reply #4 on: February 27, 2019, 01:24:02 PM »
NOTE: Both of the macros posted above have some problems.Read the discussion to see how to use them.

Phil
DesignCAD user since 1987

gavoss

  • Newbie
  • *
  • Posts: 4
Re: Removing double lines
« Reply #5 on: February 27, 2019, 01:42:58 PM »
Forgive my stupidity, but how do I create the macro's shown so I can run them?

Dr PR

  • Hero Member
  • *****
  • Posts: 5648
Re: Removing double lines
« Reply #6 on: February 27, 2019, 02:23:12 PM »
gavoss,

Lack of knowledge isn't stupidity, it is just ignorance of what we have not yet learned. All of us are ignorant of many things! I have been using DesignCAD since 1988 and every now and then a newbie shows me how to do something new!

To use a macro in DesignCAD you must do a few things:

A. First you must save the file where DesignCAD can find it.

1. Copy the macro text from the Forum and paste it into Windows Notepad (or a similar text editing program).

2. Save the macro as a simple .txt text file (not a word processor file with fonts and etc.).

3. Rename the file to "filename.d3m" where filename is whatever you want to call it so you can remember what the macro does. DesignCAD macro files must end in file type ".d3m" . "DeleteDuplicateLines.d3m" is an example.

4. Save the macro file in some folder location where DesignCAD can find it. I use this location:

C:\DesignCAD\Macros

All of the macros I use are in this folder.

NOTE: DesignCAD has a default location for macros. It is shown when you open the "Options/options/File Locations" tab and look at the "Location" entry for macros. You can copy new macros into this default location. However, every time you install an upgrade version of DesignCAD it will default to a new location for macros. But if you create your own Macro folder somewhere you can always point a new version to this folder by changing the "File Location" tab for Macros.

B. Now tell DesignCAD where to look for the macro:

5. In DesignCAD open the "Options/Options/FileLocations" tab ("Q" opens the Options Dialog, then click on the "File Locations" tab).

6. Select the "Macro" entry and click the "Change" button.

7. Type the path to the folder with the macros in the text box. This is how you tell DesignCAD where your macros are located. Close the dialog.


****

C. Now you are set to use the macro. Here's how:

8. Open the "Tools" menu and click on "Macro Execute." The "%" key is a macro execute shortcut.

9. The macro folder that you assigned above will open with a list of all the macros.

10. Select the macro from the list and click "Open"

The macro will execute.

Different macros work different ways, so you are on your own from here.

****

If you have a macro that you use often you can streamline the way it is executed:

1. You can assign keyboard "hot keys" or "shortcuts" to execute the macro.

2. You can add it to a custom tool box.

3. You can add it to a menu.

4. You can execute the macro from the command line.

How to do these things is subject for a different discussion.

Phil
DesignCAD user since 1987