Jump to content
Sign in to follow this  
ClockWerX

RGB values convertion (RealBasic --> VW)

Recommended Posts

Hi again,

I did a little experimentation and I found out that I have to multiply the values from RealBasic (ranging from 0 to 255) with 256 to match those of VectorWorks.

However I still get an color difference between what is drawn in RealBasic and the VW colors. The selected color choosen in Vectorworks is darker and not quit the same as in RealBasic. For example the following code :

procedure Test;

Var

hndLayer:handle;

hndObject:handle;

lngRed:longint;

lngGreen:longint;

lngblue:longint;

begin

SelectAll;

hndLayer := ActLayer;

hndObject := FSObject(hndLayer);

lngRed := 51200;

lngGreen := 51200;

lngBlue := 0;

SetFillBack(hndObject,lngRed,lngGreen,lngBlue);

end;

run(Test);

Will show a very different color in VectorWorks than specified in RealBasic (Red : 200 Green : 200 Blue : 0).

It is very important that both colors are the same and closely matching. I have the impression that VectorWorks choose the nearest available color in its active color palette or am I wrong?

How can I solve this problem so the Vectorworks colors are closely matching the RealBasic generated RGB colors?

I thank you again for your time spend on my problem. In the meantime I wish you the best.

Friendly greetings,

Chrissy

Share this post


Link to post

You can use the numbers of any color in VectorWorks.

Try to just add the value directly into the script instead of converting first. (There is a conversion process anyways for rgb values, but I discovered you can just use the raw numeric data.)

ex.

SetClPenFore(' classname',30583,30583,30583);

Share this post


Link to post

Hello Katerina,

Thank you very much for your reply. I tried your solution but regretfully it has also a color difference.

In case I use the raw numeric data from RealBasic (Red : 200 Green : 200 blue : 0) I got a brown color instead of the yellow like color specified. Without convertion both colors do not even come close in comparision. Believe me, I hate the convertion also and I want to avoid it at all cost (if necessary).

Specifiying values higher than 255 in RealBasic has no use because they are changed automaticly to 255.

I think when we used VW 10 or VW 11, we should not experience this problem at all because VW 10 works with color sliders which goes to 255. Regretfully we still use VW 9.5.

Maybe you ask by yourself "why using RealBasic for choosing colors?". Very simple, VectorScript dialogs do not have the capability to create colors by code and show them inside the dialog itself. In my RealBasic program the user directly see the signpanel in its dialog and every change is directly visible. In this way, the user can fine tune his/her colors before importing them (by textfile) into the Vectorworks document.

Despite the fact your advice gave me not the result I wanted, I find it very usefull because using a class, seems to me a little more responsive than using a handle to a specified object (or am I wrong?).

I thank you very much for your help and I wish you a very nice day. If I find a solution, I will let you know.

Friendly greetings,

Chrissy

Share this post


Link to post

Hi Chrissy,

You are right in assuming that VW snaps assigned colors to the nearest color palette value. Try adding the following 2 lines to the end of your program to see what value is actually assigned.

GetFillBack(hndObject, lngRed, lngGreen, lngBlue);

Message(lngRed, ' ', lngGreen, ' ', lngBlue);

Then you can take those values (/256) and plug them back into RealBasic to see how well they match.

It is also possible to add colors to a color palette. You might explore adding the chosen color from RealBasic into the VW color palette and then applying it. I don't know how well they will match, but it's worth a try.

Raymond

Share this post


Link to post

Hello Everyone,

Can you give me some advice about the following.

We are using VectorWorks 9.5 on a Macintosh G4/867 computer. We are creating signpanels.

Because it is our intention that the person who make the drawings, can create and immediatelly see the result of the choosen color.

Therefore in RealBasic a signpanel is drawn on a dialog which shows the choosen colors. Besides the signpanel are 3 sliders (Red Green Blue) for creating and adjusting signpanel colors.

RealBasic RGB values range from 0 until 255 while VectorWorks RGB values range from 0 to 65536.

To convert those values I have to multiply the RealBasic values with 256.

However I am not sure if all RealBasic colors will match those counterparts in VectorWorks. I am using a PIO - VectorScript for importing and processing the color values in VectorWorks.

Can you tell if those assumptions are correct, or is there something wrong?

I appreciate your help very much and I thank you in advance.

Friendly greetings,

Chrissy

Share this post


Link to post

Hello Raymond,

Thank you very much for your help. It is just what I am looking for.

I did some experimenting with your code and also I succeeded in manually added the RealBasic color to the VectorWorks pallet. It is created as a custom color. When I define the RealBasic color (example Red : 200 Green 200 Blue 0) into the SetFillBack command, VectorWorks takes the correct (custom) color.

But I have a new question. I like the Plugin object set the newly imported colors into the VW color palette. I searched the VectorScript 9 function reference but I could not find any command which lets me add a custom color by code. Do you know how I can add a custom color (RGB) to the VW color palette using a VectorScript command?

Both colors in VW and RB match almost perfectly. It should be nice when the color can automaticly created in VectorWorks when it does not exist. The person who design the signpanels and carry out the calculation does not want to bother with side-activities. Therefore he create the used colors for a project in RB and uses one PIO for creating the basic document with colors, worksheets, classes and layers in VW.

It is a very nice when you allow your users to work as he is used to be so they can use their creativity and imagination to their full extend.

I thank you very much for your time spent on my problem. I appreciate that very much.

I wish you all the best and you did a very nice job. I hope to hear from you again.

Friendly greetings,

Chrissy

Share this post


Link to post

Sorry Chrissy,

I do not know of a way to assign colors to the palette via VS. This appears to be another area where VS has a GET function without a SET function. I only quickly checked the v10.5 reference, perhaps it I did not see it or it has changed in v11. Maybe someone else knows better than I. Best of luck.

Raymond

Share this post


Link to post

Hello Raymond,

Thank you for your message. Indeed, I agree with you, possibly it is not possible to add custom colors by VectorScript to the VW palette.

When someone of Nemetschek read this post, they can add such a function in the next release of VectorWorks.

When I find a workaround on this problem, I will share it with you and all other people here on the forum.

I wish you a very nice day and hope to see you on this excellent forum.

Friendly greetings,

Chrissy

Share this post


Link to post
Guest

VectorWorks has a working set of 256 colors that are available to objects. If you attempt to assign a color to an object and that color is not one of the 256 colors then it will get mapped to nearest color and then assigned. This happens behind the scenes.

As was mentioned, you can edit the color palette using the dialog but not from VectorScript. I will add this to the "wishlist" (actually I think it is already there).

By the way, if you edit the color palette and change a color that was assigned to an object in the drawing, that object's color will be mapped to something close to its previous value. In other words, if you change a yellow to dark blue, then the object will try to stay yellow and VW will pick a similar yellow that is still in the newly edited palette.

Jeff

Share this post


Link to post

Hello Jeff,

Thank you for your explanation and adding this subject onto the VW wishlist.

Indeed for my solution it is very important to change the VW color palette to the newly imported (or assigned) custom RGB color. The user of my program doesn't want to be bothered by color differencies nor will he understand the reason for those color shifts.

I have to find a suitable workaround for this problem. This will not be easy but nothing is impossible or can't be done.

You have to imagine that this calculation system is modular build. The color composer is only a very small part of the calculation program in RealBasic. Besides the color composer there is an address and project mangagement and administration system present in the RB made program.

I specialised myself in those custom-made calculation solutions where the easy of use and user creativity is placed in the middle of the solution. Therefore the workaround may not limit the users creativity and must be completely transparent to him. I will find a way.

I thank you very much for your time spent on my problem and appreciate your efforts very much. Your help and the help from Katarina and Raymond where very helpfull to me.

I wish you a very nice day and all the best!

Friendly greetings,

Chrissy

[ 07-30-2004, 06:28 PM: Message edited by: ClockWerX ]

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...