News:

When posting a problem be sure to include which version you are using.  Give as much information as possible.  If the problem is with a specific file be sure to attache it to your post.

Main Menu

Graphic.Properties,Add()

Started by KeesRoos, August 25, 2021, 10:36:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

KeesRoos

In a C# Application for TurboCAD 2021 SDK I try to add a Property to a Graphic, using:
Properties.Add( string Name, ref Object Value )
as per IMSIGXMGDReference.chm.

The sourcecode I tried looks like this:
object lum = "Single\\Spot";
_Props.Add("#LW_LUMINANCE", ref lum);

This compiles without any error or warning in Visual Studio 2019 and 2022, but always results in Error:
0x800706F4 A null reference pointer was passed to the stub.

I have tried whatever I could think of, but the result was always the same.

Anybody here who can show me how to use this method properly?
Tried to ask this from IMSI, but they told me to get lost (used different terminology, but amounted to this)

Thanks in advance,
Kees Roos
TurboCAD 2018, 2019, 2020, 2021 Platinum 64 bit
Windows10 64 bit
Intel Core i9-9900K CPU, 3.6/5.0 GHZ 8 cores, 64 Gb RAM
Eizo EV 3722 3840 * 2160

nikkipollard

I am not sure. But in the macro recorder there is no # in front of the property Name. Did you try that?
Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

nikkipollard

#2
I don't know if this helps - I don't know anything about c# but this syntax works with VB.net.
It seems you have to add the property to the graphic and then set the value.
I also think that the variable type for the Luminance is a string not an Object. - not sure if that makes a difference.
One backslash not two. - I think because it is like a file name and those are the folders.


Dim g As IMSIGX.Graphic
        g = TCDraw.Graphics.Add(, "TCW40CUBE")
        With g.Vertices
            .Add(0, 0, 0)
            .Add(100, 0, 0)
            .Add(0, 100, 0)
            .Add(0, 0, 100)
        End With
        g.Properties.Item("Solid").Value = True
        g.Draw()
        g.Properties.Add("LW_LUMINANCE", "Single\Point")
        g.Properties.Item("LW_LUMINANCE").Value = "Single\Spot"


Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

John R

My two cents.

Luminance's are stored in the Luminance.dat file, which is located at "C:\Users\your user name\AppData\Roaming\IMSIDesign\TurboCAD 2021\Platinum x64\Luminance". Maybe this will help in getting the proper naming.
John R.

V17—V21, 2015—2025
Designer, Deluxe, (Basic, Expert, Professional), Platinum
RedSDK enabled
Windows 11 Pro (25H2), 64-bit

KeesRoos

@Nikki. Thanks for your prompt reaction.
"# "was a remnant of one of my experiments, you are right, it should nt be there. However, it does not solve the problem.
Unlike the Basic method which is automatically passed by reference, the C# Method requires an object passed explicitly by reference. Obviously the problem is located there.
Setting the values of properties is no problem, it is only the  addition of the property.
The double backslash is a necessary formatting of the "\" character in the C# syntax.

@John. As far as I understand, the luminances included in the AppData is a catalogue of possible choices for LightWorks. The Graphic Property tells LightWorks which one  to choose.

I found out which Property to add by comparing the Properties of the Graphic before and after setting the Luminosity of the Graphic by hand in the desktop interface, as Nikkies macro also shows.

Thanks both of you for your time, appreciate it very much. I will have to keep trying.
TurboCAD 2018, 2019, 2020, 2021 Platinum 64 bit
Windows10 64 bit
Intel Core i9-9900K CPU, 3.6/5.0 GHZ 8 cores, 64 Gb RAM
Eizo EV 3722 3840 * 2160

nikkipollard

#5
Oh I understand. That is frustrating.
It has now gone way beyond my basic understanding level
I have only ever added custom properties to graphics - which seems to use the same method.
I have only had errors, when  adding a property to a graphic when a property with the same name
is already defined for that graphic.
Defining the lum as an Object first in VB.net, also worked.
Actually it is better because It doesn't need the 2 step process of adding the property then setting the value.




Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

TedTheCarpenter

Nikki,
Here's your code converted to C#. I used a free online code converter at https://codeconverter.icsharpcode.net/. You can install it as an extension in Visual Studio. Lots of code examples are C# and I find it to be a really useful tool.{
    IMSIGX.Graphic g;
    g = TCDraw.Graphics.Add(default, "TCW40CUBE");
    {
        var withBlock = g.Vertices;
        withBlock.Add(0, 0, 0);
        withBlock.Add(100, 0, 0);
        withBlock.Add(0, 100, 0);
        withBlock.Add(0, 0, 100);
    }

    g.Properties.Item("Solid").Value = true;
    g.Draw();
    g.Properties.Add("LW_LUMINANCE", @"Single\Point");
    g.Properties.Item("LW_LUMINANCE").Value = @"Single\Spot";
}
Ted D

2017 Pro, 2018>2023 Platinum
Windows 11 Pro 22H2  64GB
Ryzen 9 5900X 12 core
Radeon RX 6600 XT 8GB

KeesRoos

@ Nikki
Defining the lum as an Object first in VB.net did not solve the problem in my code.
Thanks anyway.

@Ted,
Nikki's VB code addressed my query.
I have been away for a few days, had to teach a course, no time to attend to the discussion.

Thanks for your C# code translation of Nikki's code, tried it in my code.
However, it does not solve the problem. Error still occurs.
Hopefuly it's not a bug in TurboCAD, could take forever to get the IMSI programmers to address it.

I want to write my TurboCAD Engine in C#, in order to be able to relatively simple connect to c++ code compiled with the Intel compiler, which enables me to use 80 bit and 128 bit floats which I need for some optimising problems.

Seems that I'll have to resort to Visual Basic, but this means I will have to use the decimal type instead, which is significantly slower.

Thanks again, regards,
Kees Roos
TurboCAD 2018, 2019, 2020, 2021 Platinum 64 bit
Windows10 64 bit
Intel Core i9-9900K CPU, 3.6/5.0 GHZ 8 cores, 64 Gb RAM
Eizo EV 3722 3840 * 2160

nikkipollard

#8
I don't know I wouldn't change to vb.net just yet - It is a little flakey there too.

I was trying to figure out why  it works sometimes and not others. ( in vb.net and with ppms)
It seems that when there is already a spotlight in the active drawing then adding the property to the graphic works as expected.
If not the property is added to the graphic but the value is set to none.
I assume this is because the Add property looks in the list of luminances from the active drawing and sets it to none if it cant find the luminance.
Whereas when you try to set the value of the luminance it looks in the dat file.

Vlad is quite active on this forum maybe it would help to contact him and not support. This doesn't make any sense to me but I think he is the right person to talk too.
https://forums.turbocad.com/index.php/topic,20785.0.html

Nikki
TC20 platinum, TC 2015 platinum
TC 2017 with lightworks
TC 2021 platinum
Windows 11 Home 22h

KeesRoos

Thanks, have asked Vlad to ahve a look.
TurboCAD 2018, 2019, 2020, 2021 Platinum 64 bit
Windows10 64 bit
Intel Core i9-9900K CPU, 3.6/5.0 GHZ 8 cores, 64 Gb RAM
Eizo EV 3722 3840 * 2160