I can open a PDF with layers but it creates hundreds of them.
Instead of having ten layers there are hundreds of them with small groups of objects in those same layer names over and over.
The only way I can think to fix it is to make 10 different PDFs with each of the 10 layers and bring them in one at a time.
???
Don't see a file upload. But here is a print screen link:
The import works but why are all the layers broken up into many layers of the same name? Some have just one or two lines/objects in them. ???
Without a PDF file to try, I have no way to try importing the file myself to see if I get the same result.
If the file isn't too big, you can insert it into your post. - Insert>Insert image/video/file. You might need to put it into a ZIP archive in order to upload it; I don't know if the system will allow PDF files.
Or, you could provide a link to where you have shared the file on-line (e.g., Google Drive).
I tried importing it into CorelDRAW 2018.
The result:
6 layers named "AI-SV16-1F-ARCH|A-BLDG-FIXT" with objects in them
3 layers named "AI-SV16-1F-ARCH|A-BLDG-STRS" with objects in them
587 layers named ZZ_DeletedLayers with no objects in them.
Good to have the old DeleteEmptyLayers macro.
I didn't already have one, but it didn't take me too long to write one. That's how I knew it was 587 layers!
Do you have a "merge all layers that have the same name" macro?
No, don't have one to do that but seems easy enough huh?
For you guys maybe.
Used this to delete the empty layers and it seems to work. Not sure how to merge though.
Dim pg As PageDim lyr As LayerDim sr As ShapeRange
Private Sub DelEmptyLayer()
For Each pg In ActiveDocument.Pages For Each lyr In pg.Layers If Not lyr.IsSpecialLayer Then Set sr = lyr.Shapes.All If sr.Count = 0 Then lyr.Delete End If End If NextNext
End Sub
Here is something that you could try for consolidating the content from multiple layers that have the same name:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
Sub consolidate_layers_same_name() Dim layerThis As Layer Dim sr As ShapeRange Dim strCurLayerName As String Application.EventsEnabled = False Optimization = True ActiveDocument.BeginCommandGroup "consolidate layers same name" For Each layerThis In ActivePage.Layers If Not layerThis.IsSpecialLayer Then If Not layerThis.Shapes.FindShapes.Count = 0 Then strCurLayerName = layerThis.Name layerThis.Name = "foo" Set sr = ActivePage.Shapes.FindShapes(Query:="@com.layer.name = '" & strCurLayerName & "'") If sr.Count > 0 Then sr.MoveToLayer layerThis End If layerThis.Name = strCurLayerName End If End If Next layerThis MsgBox "Done" ActiveDocument.EndCommandGroup Optimization = False Application.EventsEnabled = True Refresh End Sub
That doesn't delete layers from which content was moved, so run that first, then follow up with a macro to delete all empty layers. You have one of your own; this is what I wrote:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Sub delete_empty_layers() Dim layerThis As Layer Dim lngEmptyLayerCount As Long Application.EventsEnabled = False Optimization = True ActiveDocument.BeginCommandGroup "delete empty layers" For Each layerThis In ActivePage.Layers If Not layerThis.IsSpecialLayer Then If layerThis.Shapes.FindShapes.Count = 0 Then layerThis.Delete lngEmptyLayerCount = lngEmptyLayerCount + 1 End If End If Next layerThis MsgBox lngEmptyLayerCount & " empty layers were deleted." ActiveDocument.EndCommandGroup Optimization = False EventsEnabled = True Refresh End Sub
Those subs are both in this .GMS file:
JQ layers stuff 2018_06_25_2038.zip
Thanks so much, that worked.
It's too bad that CorelDraw breaks them up like that. I was even looking at upgrading but it looks like 2018 has the same issue.
Tanquen said:Thanks so much, that worked.
I'm glad to hear that it works for you. I didn't have anything more complex than your sample PDF to test it.
For this content, do you have access to any graphics format other than .PDF, for example, .DWG?
We don’t always get the same documentation from the customer. They may have the CAD files but this is an old facility and we are lucky to get the PDFs that are not just scanned bitmap files. Will CorelDraw better handle DWG files with layers?
Tanquen said:Will CorelDraw better handle DWG files with layers?
Sometimes CorelDRAW will do well with .DWG files. It depends on the .DWG file; have to try it and see how well or poorly it works.