News:

BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

Find/Select all shapes by color

Started by alexburn, September 14, 2010, 12:28:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

alexburn

Is there any way that I can select all shapes on a page of a particular line color? The 'Select by type' function is almost what I need, although not specific enough to find particular shapes rather than all shapes.

I need to do this so that I can select all *red* lines imported from an existing CAD drawing so that I can then assign to a specific layer.

Thanks

Yacine

There's no such function to my knowledge, but I would suggest, that you use an intermediate file. eg: import the CAD drawing in an empty drawing, select all shapes, assign the desired layer, cut and paste in the right drawing.
Yacine

alexburn

I know that there is no in-built function, but I am pretty certain that some VB code could easily achieve a solution.

The main problem I have is with CAD, as I only have a some light CAD software on my machine, and it doesnt have the power nor functionality to modify the DWG I have. The DWG I am using is a massive site plan so that are some 50,000+ objects in total. So far I have the CAD drawing imported ok into Visio, but to go through the entire drawing to find all objects of each particular colour is taking forever!

Yacine

OK, but that is not an answer to my suggestion. ;-D
Yacine

alexburn

Your suggestion does not solve my problem. I have a CAD drawing with 1000's of items on 20+ CAD layers in 20+ different colours. I cannot import and convert the CAD drawing, all I can do is copy from CAD and past in Visio (without layer info). I need to select all items in the document that are *red* so that I can then assign them to *red layer* then select all items that are *blue* so that I can assign them to *blue layer*.

Nikolay

#5
You could try the following VBA code (selects all shapes with fill color set to "RGB(255, 0, 0)", i.e. red).
If what you are interested in is actually not fill color, but line (border) color then you'll need to use "LineColor" instead of "FillForegnd".
You might also need to tweak the color value so that it matches your "red" (you could use ShapeSheet to get the RGB code for your "red")
Also, your shapes might be groped; in this case you might need to iterate into groups (in case you need sub-shapes), the code below iterates over top-level shapes only.
BTW, I think you can assign shape a layer using code as well.


Dim s As Shape
For Each s In ActivePage.Shapes
 If s.Cells("FillForegnd").ResultStr(0) = "RGB(255, 0, 0)" Then
   ActiveWindow.Select s, visSelect
 End If
Next

alexburn

Awesome, thanks very much- this is exactly what I was looking for!

Just a quick follow on question...

What code would I need to look at the currently selected shape's LineColor and find all shapes with matching LineColors?

Thanks again

Nikolay

I think you could use something like this:


resultColor = ""
If ActiveWindow.Selection.Count = 1 Then
   Set s = ActiveWindow.Selection(1)
   resultColor = s.Cells("LineColor").ResultStr(0)
End If

alexburn

Works perfectly! Thanks again for your help.

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 288 (show)
Files included: 34 - 1306KB. (show)
Memory used: 1129KB.
Tokens: post-login.
Cache hits: 13: 0.00127s for 26,766 bytes (show)
Cache misses: 2: (show)
Queries used: 15.

[Show Queries]