Subscribe to this thread
Home - General / All posts - Drawing Background Colour Codes into a drawing’s table?
Pierre63 post(s)
#17-Aug-16 04:53

<!--[if gte mso 9]> <![endif]-->

<!--[if gte mso 9]> Normal 0 false false false EN-ZA X-NONE X-NONE <![endif]--><!--[if gte mso 9]> <![endif]--><!--[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:8.0pt; mso-para-margin-left:0cm; line-height:107%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri",sans-serif; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-fareast-language:EN-US;} <![endif]-->

Is there a way of getting the Background Colour Codes into a drwaing's table as column values? Either directly into the drawing's table or via a query into a query table so that one can export the data. This data can then be pulled into e.g. Excel where detailed legends can be built with an Excel cell having the same colour as the original Manfold drwaing.

tjhb
10,094 post(s)
#17-Aug-16 04:59

Sure. Yes.

In what form?

Pierre63 post(s)
#17-Aug-16 05:08

RGB - Red, Green, Blue will probably do? Not sure what info one can pull out. Any references on that available?

Dimitri


7,413 post(s)
#17-Aug-16 05:34

I don't think that is exposed anywhere for automated use (could be wrong). Worst case you open Tools - Options - Background Color and then in the color dialog note the RGB values. Open the table, create a new column, select all records and paste the value, assuming you have default settings where changing the value in one field sets that value for all selected rows.

I see more than half of your post is text noise... as amazing as it may be to be reminded how absurdly overweight some editors can be for simple things, I'd gently remind you of this rule:

"Please choose an editor for composing posts that will not inflict text noise on other participants. If you make a posting and it is full of strange text items that are not part of the plain text of your posting, please immediately edit the posting to remove the extraneous material."

Pierre63 post(s)
#17-Aug-16 05:37

Appologies for that. I tried to edit it, even deleted all text and re typing it but the noise do not show up in the edit window so I could not get rid of the formatting noise.

Dimitri


7,413 post(s)
#17-Aug-16 07:51

What are you using for a browser or editor? I don't see the problem either with Opera, Chrome or IE.

Personally, I use Opera with automatic ad-blocking on and VPN turned on as well. I don't like the ads and, given that I travel a lot, I don't like it when some idiotic website decides to alter the URL I give (which I choose based on my language and other preferences) to whatever local site it thinks I should have picked.

Of course if you use VPN you can get landed in whatever location the VPN proxy of the moment happens to be located, but at least that interferes with and thus slightly dilutes the misuse of location tagging mechanisms.

As far as editors go I've always found it annoying when editors do what they think you should want to do, even in the simplest things, instead of what you want to do. Just try to harvest a table from a web site, for example, to create a csv in plain text for import into a Manifold project. These days I don't even bother messing about with wordpad, notepad, etc., and just use a hexadecimal editor to adjust the inevitable idiocy surrounding carriage returns vs. line feeds vs. end of paragraph codes, etc. I like seeing what is actually in the file and making it be exactly what I want.

Pierre63 post(s)
#17-Aug-16 08:02

I use Firefox as browser but I first typed the post in MS-Word before pasting it into the post window. When posting it I saw the noise but when trying to edit it the edit window returned the text without the noise. Seems like an issue between the edit window and what is finaly displayed on the forum page.

Dimitri


7,413 post(s)
#17-Aug-16 10:10

Ah, that's Word being Word, similar to how it's not particularly useful for stripping stuff out that's being harvested from a web site. When you paste from Word into the forum you are pasting all that stuff from Word as well into what, in effect, is the HTML space of the forum. I think you would be able to see all the extras in the posted material by clicking the Raw HTML tab when you edit your post instead of the Text tab.

One way to strip all that stuff out that Word inserts is to first paste into Notepad, and then copy from Notepad and paste into the forum. Or, just compose in Notepad in the first place.

mdsumner


4,260 post(s)
#17-Aug-16 11:07

Or, in recent version of Chrome: Ctrl-SHIFT-V to paste unformatted.


https://github.com/mdsumner

atomek

422 post(s)
#17-Aug-16 11:20

I remember solving a similar problem years ago. Sorry for no ready-made solution but if my memory isnt failing the process was:

1. Generate image from your drawing

2. Generate centroids for your drawing areas

3. Transfer R, G and B values from image to centroids

4. Concentate RGB to one column

5. Save results of an SQL grouping by that column as a table

6. Generate theme.xml based on that table

Hope that helps

atomek

422 post(s)
#17-Aug-16 12:05

Ops, now I realize it must had been a scanned image I started with and not a drawing.

So if you have an already themed drawing you need to save the theme as xml and generate/parse it/ to create a table out of it. In the end you just match the colour to the columns value

tjhb
10,094 post(s)
#17-Aug-16 12:33

You could do that, but you could equally go via the object model, directly to values in a column.

ObjectSet -> Object.BackColor.Red|Green|Blue

Seems easier.

tjhb
10,094 post(s)
#18-Aug-16 02:38

Like this (sorry for the delay).

# IronPython

import clr

clr.AddReference('Manifold.Interop')

from Manifold.Interop import ColumnType # enum

#

def Main():

    log = Application.History.Log

    drw = Document.ComponentSet('Drawing')

    tbl = drw.OwnedTable

    cols = tbl.ColumnSet

    # add and adjust target columns as necessary

    for (col_name, col_type) in (

        ('Red', ColumnType.ColumnTypeInt8U),

        ('Green', ColumnType.ColumnTypeInt8U),

        ('Blue', ColumnType.ColumnTypeInt8U)

        ):

        col_index = cols.ItemByName(col_name)

        if col_index >= 0:

            # named column exists: check type

            col = cols(col_index)

            if col.Type != int(col_type):

                log('Adjust type of column [' + col_name + ']\r\n', True)

                col.Type = col_type

        else:

            # create new column

            col = cols.NewColumn()

            col.Name = col_name

            col.Type = col_type

            log('Add new column [' + col_name + ']\r\n', True)

            cols.Add(col)

#

    # populate RGB columns with formatting values

    for obj in drw.ObjectSet:

        rec = obj.Record

        colour = obj.BackColor

        rec._PutData('Red', colour.Red)

        rec._PutData('Green', colour.Green)

        rec._PutData('Blue', colour.Blue)

#

Main()

To install IronPython check here.

Attachments:
Write background colour to table.py

tjhb
10,094 post(s)
#18-Aug-16 02:58

Same thing in VBScript.

' VBScript

Option Explicit

Sub Main

    Dim drw, tbl

    Dim cols, col

    Dim newCols, desc

    Dim colIndex

    Dim obj, rec, colour

'

    Set drw = Document.ComponentSet("Drawing")

    Set tbl = drw.OwnedTable

    Set cols = tbl.ColumnSet

'

    ' add and adjust target columns as necessary

    newCols = Array( _

        Array("Red", ColumnTypeInt8U), _

        Array("Green", ColumnTypeInt8U), _

        Array("Blue", ColumnTypeInt8U) _

        )

    For Each desc In newCols

        colIndex = cols.ItemByName(desc(0))

        If colIndex >= 0 Then

            ' named column exists: check type

            Set col = cols(colIndex)

            If col.Type <> desc(1) Then

                Application.History.Log "Adjust type of column [" + desc(0) + "]" + vbCrLf, True

                col.Type = desc(1)

            End If

        Else

            ' create new column

            Set col = cols.NewColumn

            col.Name = desc(0)

            col.Type = desc(1)

            Application.History.Log "Add new column [" + desc(0) + "]" + vbCrLf, True

            cols.Add(col)

        End If

    Next ' desc

'

    ' populate RGB columns with formatting values

    For Each obj In drw.ObjectSet

        Set rec = obj.Record

        Set colour = obj.BackColor

        rec.Data("Red") = colour.Red

        rec.Data("Green") = colour.Green

        rec.Data("Blue") = colour.Blue

    Next ' obj

End Sub

Attachments:
Write background colour to table.vbs

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.