Author Topic: c# - Plugin Questions  (Read 95055 times)

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5332
  • Made in England
    • View Profile
Re: c# - Plugin Questions
« Reply #15 on: January 26, 2022, 15:28:08 pm »
profile.InsideOutside = new CamBam.Values.CBValue<InsideOutsideOptions>(InsideOutsideOptions.Outside);

profile.InsideOutside = new CamBam.Values.CBValue<InsideOutsideOptions>(InsideOutsideOptions.Inside);
Filmed in Supermarionation

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 231
  • Jam it !
    • View Profile
Re: c# - Plugin Questions
« Reply #16 on: January 27, 2022, 09:21:11 am »
THX, only aliens are able to figure that out.  ;D
best regards

Bernhard

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 231
  • Jam it !
    • View Profile
Re: c# - Plugin Questions
« Reply #17 on: January 27, 2022, 13:28:33 pm »
And the next question refers to c# itself...

I hope you "feel" what I want to do, I am a C# rookie.

C# is moaning, of course, because I want to assign new objects of similar, but different types.
(Python was very "tolerant" about that)

I hope MOPProfile, MOPPocket.... are derived from MachineOp ?

Code: [Select]
                    MachineOp profile;

                        switch (command)
                        {
                            case "I":
                                profile = new MOPProfile(newdoc, newdoc.Layers[LayerIndex].Entities.ToArray());
                                profile.InsideOutside = new CamBam.Values.CBValue<InsideOutsideOptions>(InsideOutsideOptions.Inside);
                                break;
                            case "O":
                                profile = new MOPProfile(newdoc, newdoc.Layers[LayerIndex].Entities.ToArray());
                                profile.InsideOutside = new CamBam.Values.CBValue<InsideOutsideOptions>(InsideOutsideOptions.OutSide);
                                break;
                            case "P":
                                profile = new CamBam.CAM.MOPPocket(newdoc, newdoc.Layers[LayerIndex].Entities.ToArray());
                                break;

                        }
best regards

Bernhard

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5332
  • Made in England
    • View Profile
Re: c# - Plugin Questions
« Reply #18 on: January 27, 2022, 19:46:29 pm »
See what this does.

Code: [Select]
  MOPFromGeometry profile;

             switch (command)
            {
                case "I":
                    MOPProfile pro = new MOPProfile(newdoc, newdoc.Layers[LayerIndex].Entities.ToArray());
                    pro.InsideOutside = new CamBam.Values.CBValue<InsideOutsideOptions>(InsideOutsideOptions.Inside);
                    profile = pro as MOPProfile;
                    break;
                case "O":
                    MOPProfile pro2 = new MOPProfile(newdoc, newdoc.Layers[LayerIndex].Entities.ToArray());
                    pro2.InsideOutside = new CamBam.Values.CBValue<InsideOutsideOptions>(InsideOutsideOptions.Outside);
                    profile = pro2 as MOPProfile;
                    break;
                case "P":
                    MOPPocket pocket = new MOPPocket(newdoc, newdoc.Layers[LayerIndex].Entities.ToArray());
                    profile = pocket as MOPPocket;
                    break;
            }
 

Filmed in Supermarionation

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 9086
    • View Profile
Re: c# - Plugin Questions
« Reply #19 on: January 27, 2022, 20:02:58 pm »
Man, Eddy!  I _used_to_ program in C and C++.  I think I've forgotten more about them than I knew! <grin>

But I see you literally JUMP on a problem like this, and it impresses the heck out of me.

I sure hope you keep it up!

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 231
  • Jam it !
    • View Profile
Re: c# - Plugin Questions
« Reply #20 on: January 27, 2022, 21:33:25 pm »
Yehaaaaa, thanks !

I'll try tomorrow, actually it's beer drinking time here in good ole Germany !

Once upon a time (approx.25 years) I was a software developing engineer,
but in between there is so much I have forgotten and  there is so much new stuff to learn.

Cheers !
best regards

Bernhard

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 231
  • Jam it !
    • View Profile
Re: c# - Plugin Questions
« Reply #21 on: January 28, 2022, 08:13:05 am »
Now it´s coffetime here in good ole Germany
and Eddie´s solution works like a charm.

Thanks again !
best regards

Bernhard

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5332
  • Made in England
    • View Profile
Re: c# - Plugin Questions
« Reply #22 on: January 28, 2022, 14:18:08 pm »
Bernhard,

The first line should be ;

MOPFromGeometry profile = new MOPFromGeometry();

otherwise "profile" is flagged as an unassigned variable
Filmed in Supermarionation

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5332
  • Made in England
    • View Profile
Re: c# - Plugin Questions
« Reply #23 on: January 28, 2022, 14:26:36 pm »
Man, Eddy!  I _used_to_ program in C and C++.  I think I've forgotten more about them than I knew! <grin>

But I see you literally JUMP on a problem like this, and it impresses the heck out of me.

I sure hope you keep it up!

Lloyd

Lloyd,

I'm with you on what you said here, "I think I've forgotten more about them than I knew!"
These days it's more about knowing what to look for, knowing where to look, and knowing how to look.

I like to think that if my spaceship crashed on Mars, I would be able to patch it up to get back
Filmed in Supermarionation

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 231
  • Jam it !
    • View Profile
Re: c# - Plugin Questions
« Reply #24 on: January 28, 2022, 14:34:14 pm »
(Yes Eddy, you´re so right.)


Ha !

And I figured out by myself (YES!)  ;D

 instead of
  MOPFromGeometry profile;

I use
 dynamic profile;

so I can access properties at runtime, which are not defined in MOPFromGeometry at compiling!

Cheers !

best regards

Bernhard

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 231
  • Jam it !
    • View Profile
Re: c# - Plugin Questions
« Reply #25 on: January 31, 2022, 12:55:20 pm »
Hossa !
And here´s the next question :
I can´t figure out how to set the LeadIn/Out SpiralAngles using c#.

using pythons it works like this
Code: [Select]
                    LeadInfo = profile.LeadInMove.Cached
                    LeadInfo.SpiralAngle = (float) (Parameter)   
                    profile.LeadInMove = CBValue[LeadMoveInfo] (LeadInfo)

Best regards

Bernhard
best regards

Bernhard

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5332
  • Made in England
    • View Profile
Re: c# - Plugin Questions
« Reply #26 on: January 31, 2022, 14:46:32 pm »
I wasn't really convinced that the switch(command) section we talked about earlier was going to work, I think that's the problem.
Filmed in Supermarionation

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 231
  • Jam it !
    • View Profile
Re: c# - Plugin Questions
« Reply #27 on: January 31, 2022, 17:09:34 pm »
Oh, this runs very fine in any case !

But I have problems to figure out how to handover data to the leading in/out structures.
best regards

Bernhard

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5332
  • Made in England
    • View Profile
Re: c# - Plugin Questions
« Reply #28 on: January 31, 2022, 20:00:01 pm »
Try this;

 LeadMoveInfo LeadInfo = new LeadMoveInfo();
 LeadInfo = profile.LeadInMove.Cached;
 LeadInfo.SpiralAngle = 5;
 profile.LeadInMove = new CamBam.Values.CBValue<LeadMoveInfo>(LeadInfo);
Filmed in Supermarionation

Offline ThisAmplifierIsLoud

  • Storm Trooper
  • ***
  • Posts: 231
  • Jam it !
    • View Profile
Re: c# - Plugin Questions
« Reply #29 on: February 01, 2022, 08:59:19 am »
I tried, but it crashes at runtime applying to a MOPRrofile.
See what happens.

 :'(


best regards

Bernhard