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.

Merging points when importing a dxf file

Started by Eric Snyder, July 23, 2010, 07:46:21 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Eric Snyder

I have a need to import DXF files from Illustrator. The issue is most of the entities that are created in the export to DXF by Illustrator are disconnected. I need there to be no gaps between end points of entities. Is there a way to merge these endpoints that does not involve hand editing 1,600 entities?

Rob S


There are several possibilities I can think of - none of them very easy - and depends much on how clean the drawing is in terms of what is to be joined and what not.

If the points are precisely on the same spot, just the entities are separate vectors, the combine lines command can be used on multiple selections - it will join anything it can.

A single pair or group of Points close to each other can be made co-incident using the "join endpoints" command.

A macro could probably be devised to select segments with nearby endpoints and join them, but this would only work if only line segments to be joined were close by and no other points close by.

A small sample drawing might help us see what could be done
User since forever

Bob P

I did a similar (but different) thing in DC DOS when I cycled through all the entities looking for duplicate lines.  Be aware that the process could take quite a while since there would be 1600! (factorial) operations involved.
Obviously, this only shows the applicable cycling process and the situation would have to be modified for 3D entities.

My DOS macro:

'This removes all duplicate lines
'Figure the approximate operation time
TIME=(INT(10*((SYS(9)/102)^2)))/90
WINDOW 9,35
LOCATE 2,5
PRINT "This will take up to "
LOCATE 4,5
PRINT TIME, "Minutes to complete"
LOCATE 8,3
INPUT "Do you want to continue? Y/N " ANS$
ASKAG2:
ANS=0
IF ANS$="Y" OR ANS$="y" THEN ANS=1
IF ANS$="N" OR ANS$="n" THEN ANS=2
IF ANS=0 THEN GOTO ASKAG2
IF ANS>1 THEN GOTO END
WCLOSE
ASKAG:
INPUT "REMOVE LINES EVEN IF IN DIFFERENT LAYERS? " ANS$
ANS=0
IF ANS$="Y" OR ANS$="y" THEN ANS=1
IF ANS$="N" OR ANS$="n" THEN ANS=2
IF ANS=0 THEN GOTO ASKAG
WINDOW 7,35
LOCATE 2,5
PRINT "Removing duplicate lines - "
LOCATE 6, 10
PRINT "PLEASE WAIT......"
LOCATE 4, 5
PRINT "This could take a while!"
MSTAT=SYS(26)
SYS(26)=2   'MANIPULATES ALL LAYERS
FOR J=1 TO SYS(9)
'Find out whether the entity is a two-point line:
GETATTR J, TYPE, SELECT, LAYER1, GROUP, COLOR
IF TYPE<>1 OR SYS(1)>2 THEN GOTO NEXTL
ENTITY J
POINTVAL X1 Y1 1     
'Gets the points of the entity into X1,Y1 and X2,Y2
POINTVAL X2 Y2 2
SYS(1)=0
GOSUB TESTL
NEXT J
NUMSEL=0
FOR K=1 TO SYS(9)
GETATTR K, TYP, SEL, LAY, GRP, COL
IF SEL=1 THEN NUMSEL=NUMSEL+1
NEXT K
IF NUMSEL<1 THEN GOTO NODUPES
>ERASE
SYS(26)=MLSTAT
>REGEN
GOTO END

TESTL:
'Cycle through other lines from last to J+1
FOR N=J+1 TO SYS(9)
GETATTR N, TYPE, SELECT, LAYER, GROUP, COLOR
IF ANS=2 THEN GOTO ANS2
IF TYPE <>1 OR SYS(1)>2 THEN GOTO NEXTL
'Selects only line entities, different layers possible
GOTO DOIT
ANS2:
IF LAYER<>LAYER1 THEN GOTO NEXTL
IF TYPE<>1 OR SYS(1)>2 THEN GOTO NEXTL
'Selects only line entities in the same layer
DOIT:
ENTITY N
POINTVAL X3 Y3 1
POINTVAL X4 Y4 2
SYS(1)=0
MATCH=0
'Test if either endpoint of the first line is coincident with the first
'point of the second line
IF ABS(X1-X3)<.001 AND ABS(Y1-Y3)<.001 THEN GOTO TEST1
IF ABS(X2-X3)<.001 AND ABS(Y2-Y3)<.001 THEN GOTO TEST2
NEXTL:
NEXT N
RETURN

TEST1:  'Test for coincidence of other points
IF ABS(X2-X4)<.001 AND ABS(Y2-Y4)<.001 THEN GOTO DELLINE
GOTO NEXTL

TEST2:
IF ABS(X1-X4)<.001 AND ABS(Y1-Y4)<.001 THEN GOTO DELLINE
GOTO NEXTL

DELLINE:
PUTATTR N, TYPE, 1, LAYER, GROUP, COLOR
'Selects entity
GOTO NEXTL

NODUPES:
WCLOSE
WINDOW 5,43
LOCATE 2,2
PRINT "THERE ARE NO DUPLICATES IN THE DRAWING!"
LOCATE 3,3
PRINT "PRESS ANY KEY TO CONTINUE..."
ANYKEY

END:

Dr PR

Eric,

If nothing else works and you are desperate enough you can edit lines in Point Select mode (CTRL 1 toggles the mode). In this mode when you select a line all points are shown as little squares. You can select an end point at a gap in the lines and drag the point to the end of the neighboring line.

If you select two lines and press the "B" key (Edit/Selection Edit/Combine Lines) the two lines will be combined into one IFF the end points are cooincident. If not the command reports the lines couldn't be connected. If so you can use Point Select mode to make end points cooincident and use the "Combine Lines" function again.

Sometimes it is much easier just to use gravity snap to trace over the original lines on a new layer, then delete the originals.
DesignCAD user since 1987

DrollTroll

There's also the Edit/Line Edit/Line Connect command. This will draw a new line segment to close a gap between two lines and combine them into one. This is a different result than gravity-snapping points together or using Trim One Line or Trim Two Lines to close the gap. It can be handy when you just want to close a gap without affecting the shapes of the original not-quite-touching lines. Unfortunately, it's not recursive, so you'll have to keep pressing F3 a lot if you need to join a bunch of lines this way.

Someone who's got the time might be able to come up with a macro that lets you set a bunch of points, then processes them two at a time to use the command iteratively.
25 years with DesignCAD