×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

MathSof 3D component

MathSof 3D component

MathSof 3D component

(OP)
Does anybody know how to use (methods, events and properties) the MathSoft 3D plot componet?
I need to plot a function f:RxR->R (a 3D plot) inside of a Visual Basic application. How can I do it?

RE: MathSof 3D component

Hi Fosil,

I haven't spent enough time playing with the Mathsoft 3D control to understand it completely, but I did figure out some things in the couple minutes I've spent with it.

First off, I don't have Visual Basic per se, but I do have access to the Visual Basic editor function that comes with Microsoft Office for writing macros.

I take it that you already know how to go to Tools>Additional Controls and add the 3D Plot control.  And that you alreday know how to go to Tools>References and add the Mathsoft 3D Plot Module. (Notice that this references the C:\Program Files\Mathsoft\Mathcad 2001 Professional\gl.dll file)

Once the OpenGL control is in your toolbox, you can add it to your form.  Right clicking on it gives you the properties.  There are a lot of properties!!

This is where I got stuck too, because when I type OpenGL1. the pop up menu comes up showing all of the properties and the functions.  The problem though is that the VB editor is not smart enough to figure out what the function syntax for each property/function is.

I decided to dig a little deeper into the gl.dll file mentioned above.

I downloaded PE Explorer, a DLL viewer program from http://www.heaventools.com/download.htm.
It's only a 30-day trial, so you'll have to work fast :P

Install this program and then open that gl.dll file.
Then go to the Resource Viewer/Editor and take a look under TYPELIB.

You'll see this:

//Mathsoft 3-D Plot module
//Version: 9.0
GLLib;
GUID = {273E49A2-02DE-11D1-9AE9-0000C008720B};


//Dispatch interface for Mathsoft 3-D Plot Control
//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch _DOpenGL;
GUID = {273E49A3-02DE-11D1-9AE9-0000C008720B};
  ShowBackplanes: I1;
  Title: BSTR;
  Tilt: R4;
  Twist: R4;
  Rotation: R4;
  RenderFilled: I2;
  RenderHiddenLine: I2;
  RenderAlternate: I2;
  RenderLines: I2;
  RenderPoints: I2;
  RenderWireFrame: I2;
  RenderContour: I2;
  TitlePosition: I2;
  NumberOfModels: I2;
  Lighting: I1;
  Fog: I1;
  FogMode: I2;
  FogColor: I4;
  FogDensity: R4;
  FogStart: R4;
  FogEnd: R4;
  AmbientLight: I4;
  Radius: R8;
  PerspectiveView: I1;
  ViewingDistance: I2;
  ConstrainedView: I1;
  PerimeterAxes: I2;
  CornerAxes: I2;
  NoAxes: I2;
  HardwareRendering: I1;
  ModelBox: IDispatch;
  BorderColor: I4;
  ShowBorder: I1;
  ViewAsContourPlot: I2;
  ViewAsDataPoints: I2;
  ViewAsBarPlot: I2;
  ViewAsPatchPlot: I2;
  ViewAsSurfacePlot: I2;
  ViewAsVectorFieldPlot: I2;
  LayoutMatrix: I2;
  LayoutStacked: I2;
  LayoutSideBySide: I2;
  VerticalScale: I2;
  GraphTitle: BSTR;
  GraphTitlePosition: I2;
  TitlePosAbove: I2;
  TitlePosBelow: I2;
  TitlePosHidden: I2;
  ConnectByRow: I2;
  ConnectByX: I2;
  ConnectByY: I2;
  ConnectByZ: I2;
  SolidLine: I2;
  DashedLine: I2;
  DottedLine: I2;
  DaDotLine: I2;
  DotSymbol: I2;
  XSymbol: I2;
  PlusSymbol: I2;
  BoxSymbol: I2;
  DiamondSymbol: I2;
  HighQualityPrinting: I1;
  Moveable: I1;
  function CreateLight(out num: I2): I1; stdcall;
  function AddSurfaces(out surfaces: Variant): I1; stdcall;
  function RemoveSurfaces: I1; stdcall;
  function Render: I1; stdcall;
  function AddVolumes(out volumes: Variant): I1; stdcall;
  function MakeCurrent: I1; stdcall;
  function MakeNotCurrent: I1; stdcall;
  function Aspect: R8; stdcall;
  function PolygonOffset(out factor: R4; out units: R4); stdcall;
  function AddSurface(out surface: Variant): I1; stdcall;
  function AddParametricSurface(out surf_x: Variant; out surf_y: Variant; out surf_z: Variant): I1; stdcall;
  function Light(out n: I2): IDispatch; stdcall;
  function DestroyLight(out num: I2): I1; stdcall;
  function Model(out n: I2): IDispatch; stdcall;
  function CreateModel(out modelNum: I2): IDispatch; stdcall;
  function AddVectorFieldPlot(out re: Variant; out im: Variant): I1; stdcall;
  function SetDefaultHighQualityPrinting(out bHighQuality: I1): I1; stdcall;
  function AddScatterPlot(out surf_x: Variant; out surf_y: Variant; out surf_z: Variant): I1; stdcall;
  function AboutBox; stdcall;

//Event interface for Mathsoft 3-D Plot Control
//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch _DOpenGLEvents;
GUID = {273E49A4-02DE-11D1-9AE9-0000C008720B};
  function MouseDown(out Button: I2; out Shift: I2; out x: OLE_XPOS_PIXELS; out y: OLE_YPOS_PIXELS); stdcall;
  function Click; stdcall;
  function DblClick; stdcall;
  function Error(out Number: I2; out Description: ^BSTR; out Scode: Error; out Source: BSTR; out HelpFile: BSTR; out HelpContext: I4; out CancelDisplay: ^I1); stdcall;
  function KeyDown(out KeyCode: ^I2; out Shift: I2); stdcall;
  function KeyPress(out KeyAscii: ^I2); stdcall;
  function KeyUp(out KeyCode: ^I2; out Shift: I2); stdcall;
  function MouseMove(out Button: I2; out Shift: I2; out x: OLE_XPOS_PIXELS; out y: OLE_YPOS_PIXELS); stdcall;
  function MouseUp(out Button: I2; out Shift: I2; out x: OLE_XPOS_PIXELS; out y: OLE_YPOS_PIXELS); stdcall;
  function ReadyStateChange; stdcall;

//Mathsoft 3-D Plot Control
//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
CoClass OpenGL;
GUID = {273E49A5-02DE-11D1-9AE9-0000C008720B};

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch IglLight;
GUID = {21787A22-8C49-11D1-9B80-0000C008720B};
  function QueryInterface(riid: ^GUID; out ppvObj: ^^VOID); stdcall;
  function AddRef: UI4; stdcall;
  function Release: UI4; stdcall;
  function GetTypeInfoCount(out pctinfo: ^UINT); stdcall;
  function GetTypeInfo(itinfo: UINT; lcid: UI4; out pptinfo: ^^VOID); stdcall;
  function GetIDsOfNames(riid: ^GUID; rgszNames: ^^I1; cNames: UINT; lcid: UI4; out rgdispid: ^I4); stdcall;
  function Invoke(dispidMember: I4; riid: ^GUID; lcid: UI4; wFlags: UI2; pdispparams: ^DISPPARAMS; out pvarResult: ^Variant; out pexcepinfo: ^EXCEPINFO; out puArgErr: ^UINT); stdcall;
  property-put Specular(: I4); stdcall;
  property-get Specular: I4; stdcall;
  property-put Diffuse(: I4); stdcall;
  property-get Diffuse: I4; stdcall;
  property-put PosX(: R4); stdcall;
  property-get PosX: R4; stdcall;
  property-put PosY(: R4); stdcall;
  property-get PosY: R4; stdcall;
  property-put PosZ(: R4); stdcall;
  property-get PosZ: R4; stdcall;
  property-put ID(: I2); stdcall;
  property-get ID: I2; stdcall;
  property-put PositionScale(: R4); stdcall;
  property-get PositionScale: R4; stdcall;
  property-put Enabled(: I2); stdcall;
  property-get Enabled: I2; stdcall;

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
CoClass glLight;
GUID = {21787A23-8C49-11D1-9B80-0000C008720B};

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch IglModel;
GUID = {4A81A57C-8DE0-11D1-9B87-0000C008720B};
  Shininess: I2;
  SmoothShading: I4;
  DrawLines: I2;
  DrawPoints: I2;
  DrawXContours: I2;
  DrawYContours: I2;
  DrawZContours: I2;
  HiddenLineRemoval: I2;
  LineColor: I4;
  PointColor: I4;
  PolygonColor: UI4;
  LineColorMap: I2;
  PointColormap: I2;
  PolygonColormap: I2;
  LineWidth: R4;
  PointSize: R4;
  DrawFilledPolygons: I2;
  DrawHalfFilledPolygons: I2;
  ViewAs: I2;
  PolygonOffsetFactor: R4;
  BarPlotLayout: I2;
  InterpolatedRows: I2;
  InterpolatedColumns: I2;
  SpectrumX: I1;
  SpectrumY: I1;
  SpectrumZ: I1;
  InterpolateMesh: I1;
  FillXContours: I1;
  FillYContours: I1;
  FillZContours: I1;
  NumberOfContoursX: I2;
  NumberOfContoursY: I2;
  NumberOfContoursZ: I2;
  NumberedContoursX: I1;
  NumberedContoursY: I1;
  NumberedContoursZ: I1;
  AutoContourX: I1;
  AutoContourY: I1;
  AutoContourZ: I1;
  ColormapIndex: I2;
  BarPlotSpacing: I2;
  DataPointsConnectivity: I2;
  LineStyle: I2;
  PointSymbol: I2;
  DrawXContours3D: I2;
  DrawYContours3D: I2;
  DrawZContours3D: I2;
  FillXContours3D: I1;
  FillYContours3D: I1;
  FillZContours3D: I1;
  AutoContourX3D: I1;
  AutoContourY3D: I1;
  AutoContourZ3D: I1;
  NumberOfContoursX3D: I2;
  NumberOfContoursY3D: I2;
  NumberOfContoursZ3D: I2;
  ScatterPoints: I1;
  ScatterLines: I1;
  BarPoints: I1;
  PatchPoints: I1;
  VectorLines: I1;
  BarLines: I1;
  PatchLines: I1;
  VectorFilled: I1;
  BarFilled: I1;
  PatchFilled: I1;
  BarHalfFilled: I1;
  PatchHalfFilled: I1;
  DrawContourLines: I1;
  DrawFilledContours: I1;
  ContourLines3D: I1;
  IsQuickplot: I1;

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
CoClass glModel;
GUID = {4A81A57E-8DE0-11D1-9B87-0000C008720B};

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch IglAxis;
GUID = {F2D2A214-A21F-11D1-A596-0A1C32000000};
  Numbered: I1;
  Label: BSTR;
  MinVal: R8;
  MaxVal: R8;
  NumGrids: I2;
  ShowLabel: I1;
  LabelFont: IDispatch;
  DataMin: R8;
  DataMax: R8;
  AxisColor: I4;
  AutoGridAxis: I1;
  AutoScaleAxis: I1;
  NumSubdivisions: I2;
  GridLineWeight: I2;
  SubGridLineWeight: I2;
  AxisLineWeight: I2;
  TickMarkWeight: I2;

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
CoClass glAxis;
GUID = {F2D2A216-A21F-11D1-A596-0A1C32000000};

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch IglBackPlane;
GUID = {C463E873-BA9D-11D1-A5D1-32C6AB000000};
  ShowHorizontalGridLines: I1;
  ShowVerticalGridLines: I1;
  Fill: I1;
  FillColor: I4;
  VerticalGridColor: I4;
  IsXY: I1;
  IsYZ: I1;
  IsXZ: I1;
  ShowHorizontalSubdivisions: I1;
  ShowVerticalSubdivisions: I1;
  HorizontalSubdivisionColor: I4;
  VerticalSubdivisionColor: I4;
  HorizontalGridColor: I4;
  ShowHorizontalTickMarks: I1;
  ShowVerticalTickMarks: I1;
  HorizontalTickMarkColor: I4;
  VerticalTickMarkColor: I4;
  HorizontalGridLineWeight: I2;
  VerticalGridLineWeight: I2;
  HorizontalSubdivisionWeight: I2;
  VerticalSubdivisionWeight: I2;
  VerticalTickMarkWeight: I2;
  HorizontalTickMarkWeight: I2;
  Border: I1;
  ShowHorizontalSubTickMarks: I1;
  ShowVerticalSubTickMarks: I1;
  HorizontalSubTickMarkColor: I4;
  VerticalSubTickMarkWeight: I2;
  VerticalSubTickMarkColor: I4;
  HorizontalSubTickMarkWeight: I2;
  function SetXY; stdcall;
  function SetYZ; stdcall;
  function SetXZ; stdcall;

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
CoClass glBackPlane;
GUID = {C463E875-BA9D-11D1-A5D1-32C6AB000000};

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch IglModelBox;
GUID = {BAB7F694-BCD8-11D1-A5D6-CA9EBA000000};
  XAxis: IDispatch;
  YAxis: IDispatch;
  ZAxis: IDispatch;
  XYPlane: IDispatch;
  XZPlane: IDispatch;
  YZPlane: IDispatch;
  AxesStyle: I2;
  BoxColor: I4;
  ShowBox: I1;
  function GetAssociatedBackplane(out axis: I2): IDispatch; stdcall;

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
CoClass glModelBox;
GUID = {BAB7F695-BCD8-11D1-A5D6-CA9EBA000000};

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch IGLPropertySheet;
GUID = {8CF2AD61-0AAD-11D2-A67F-588186000000};

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
CoClass GLPropertySheet;
GUID = {8CF2AD63-0AAD-11D2-A67F-588186000000};

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch IBackPlanePropSink;
GUID = {DA6160FF-33AA-11D2-97A9-00104B38A38C};
  ShowHorizontalGridLines: I1;
  ShowVerticalGridLines: I1;
  ShowHorizontalTickMarks: I1;
  ShowVerticalTickMarks: I1;
  HorizontalGridColor: I4;
  VerticalGridColor: I4;
  HorizontalGridLineWeight: I2;
  VerticalGridLineWeight: I2;

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
CoClass BackPlanePropSink;
GUID = {DA616101-33AA-11D2-97A9-00104B38A38C};

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch IModelPropSink;
GUID = {DA616102-33AA-11D2-97A9-00104B38A38C};
  DrawZContours: I1;
  FillZContours: I1;
  DrawWireframe: I1;
  FillSurface: I1;
  DrawZContours3D: I1;
  FillZContours3D: I1;
  ViewAs: I2;
  FillContours: I1;
  DrawContours: I1;
  DrawContours3D: I1;

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
CoClass ModelPropSink;
GUID = {DA616104-33AA-11D2-97A9-00104B38A38C};

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
Dispatch IFloatSpinButtonCtrl;
GUID = {3FD0D5EE-3AB2-11D2-97B1-00104B38A38C};
  LowerLimit: R4;
  UpperLimit: R4;
  Divisions: I4;

//Help File:    C:\Program Files\MathSoft\Mathcad 2001 Professional\gl.hlp
CoClass FloatSpinButtonCtrl;
GUID = {3FD0D5EF-3AB2-11D2-97B1-00104B38A38C};


This is the type library that is used to interface this DLL.
Each property/function has parameters that have certain data types.  Here's what I could find about COM (Component Object Model) types:


float                 float
i1                    char
i2                    short
i4                    long
r4                    float
r8                    double
string                BSTR
time                  DATE
time.tz               DATE
ui1                   unsigned char
ui2                   unsigned short
ui4                   unsigned long

(source: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/upnp/upnp/mapping_service_description_data_types_to_idl_data_types.asp)

As far as I can tel, "^" means "pointer to"

That's as far as I got.  I couldn't find any examples using gl.dll.  I highly doubt that Mathcad would have any documentation on these controls, but I could be wrong.

So, I guess it's up to you to figure out the syntax and data structures via trial and error. :)

Hope that helped, or at least got you started!

Matt
(m-valerio@onu.edu)


RE: MathSof 3D component

Hello Fosil,

Did you get anywhere with this investigation. I am trying to do something similar!

RE: MathSof 3D component

What version of VB are you using?

RE: MathSof 3D component

I am actually using Borland C++ Builder Version 5.0. I have pretty muched sussed out what I wanted to achieve using TVaraint class and Safe Arrays. I created a C++ Component (called OpenGL1)based on the OCX and then used the following code to load data into safe arrays and then pointed my TVariant at the safe array.


         TVariant userVariant,X,Y,Z;

// no set up pointers to these Variants
         TVariant* pVariant=&userVariant, *pX=&X, *pY=&Y, *pZ=&Z;
         int iType = varDouble;
         double theta,x_i;
         VariantInit(pVariant);
         VariantInit(pX);
         VariantInit(pY);
         VariantInit(pZ);
         int iMax = 26;

         SAFEARRAY *pXArray,*pYArray,*pZArray;
         SAFEARRAYBOUND xDim[2],yDim[2], zDim[2];
         zDim[0].lLbound = 0;
         zDim[0].cElements = iMax;
     zDim[1].lLbound = 0;
         zDim[1].cElements = iMax;

         xDim[0].lLbound = 0;
         xDim[0].cElements = iMax;
     xDim[1].lLbound = 0;
         xDim[1].cElements = iMax;

         yDim[0].lLbound = 0;
         yDim[0].cElements = iMax;
     yDim[1].lLbound = 0;
         yDim[1].cElements = iMax;


         pVariant->vt = VT_ARRAY | iType;
         pX->vt = VT_ARRAY | iType;
         pY->vt = VT_ARRAY | iType;
         pZ->vt = VT_ARRAY | iType;

          // Three off Two dimensional Array Required
         pXArray = SafeArrayCreate(iType, 2, xDim);
         pYArray = SafeArrayCreate(iType, 2, yDim);
         pZArray = SafeArrayCreate(iType, 2, zDim);


         double *dwArray = NULL;
         SafeArrayAccessData(pXArray, (void**)&dwArray);
         SafeArrayAccessData(pYArray, (void**)&dwArray);
         SafeArrayAccessData(pZArray, (void**)&dwArray);

     for(int nY = 0; nY < iMax ; nY++)
            for(int nX = 0; nX < iMax ; nX++) {
                        accessIndex[0] = nX;
                        accessIndex[1] = nY;
                        theta = (double)nX * 2 * M_PI /(iMax-1);
                        x_i = (double)nY*M_PI_2 / (iMax-1);
                        value = x_i*cos(theta);
                        SafeArrayPutElement(pXArray,accessIndex,&value);
                        value = x_i*sin(theta);
                        SafeArrayPutElement(pYArray,accessIndex,&value);
                        value = GetAntennaArrayGain(theta,x_i);
                        SafeArrayPutElement(pZArray,accessIndex,&value);
                        }


        SafeArrayUnaccessData(pXArray);
        SafeArrayUnaccessData(pYArray);
        SafeArrayUnaccessData(pZArray);



        pX->SetSAFEARRAY(pXArray);
        pY->SetSAFEARRAY(pYArray);
        pZ->SetSAFEARRAY(pZArray);
        OpenGL1->AddParametricSurface(pX,pY,pZ);
        OpenGL1->MakeCurrent();
        OpenGL1->Render();

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close