Reply

Using AddFiniteExtrudedProtrusion in VBScript

[ Edited ]

 

Hi

 

I have some code that work in Visual Basic that I'm unable to use from a VBScript.  I always get an invalid parameter type.  I beleive it is related to the array parameter but I'm not sure.

 

Thanks

Pascal

Public oSEApp

Public oSEDoc

Public lConnect

...

const igRight                   = 2

const PartViewFit               = 32821

...

 

Function SECreateBoxPart(sMaterial, nX, nY, nZ)

Dim ProfileArray(1)

 

    IF lConnect Then

        'On Error Resume Next

 

        Set oSEDoc = oSEApp.Documents.Add("SolidEdge.PartDocument")

        IF sMaterial "" Then

            Call oSEMatTable.ApplyMaterial(oSEDoc, sMaterial)

        End If

        Set SECreateBoxPart = oSEDoc

 

        Set ProfileArray(0) = oSEDoc.ProfileSets.Add.Profiles.Add(oSEDoc.RefPlanes(1))

        Call ProfileArray(0).Lines2d.AddBy2Points(0, 0, nX, 0)

        Call ProfileArray(0).Lines2d.AddBy2Points(nX, 0, nX, nY)

        Call ProfileArray(0).Lines2d.AddBy2Points(nX, nY, 0, nY)

        Call ProfileArray(0).Lines2d.AddBy2Points(0, nY, 0, 0)

        'The following line fail in VBScript but is okay in Visual Basic

        Call oSEDoc.Models.AddFiniteExtrudedProtrusion(1, ProfileArray, igRight, nZ)

        Call oSEApp.StartCommand(PartViewFit)

 

    Else

        Msgbox "Not connected to SolidEdge!", vbOKOnly + vbCritical, "Error"

    End If

End Function

 

 

Posted by: Pascal Boivin
Post date: 7/21/2009 4:37:54 AM

8 REPLIES

RE: Using AddFiniteExtrudedProtrusion in VBScript

[ Edited ]

Pascal,

You are right.

It is mandatory to declare the ProfileArray(1) as Profile or Object.

Even in VB6 you can't declare it like this:

 

Dim ProfileArray(1)

 

It is declared internally as a Variant which gives an error.

I don't know about any solution for this.

Regards,

Julian

 

Posted by: Julian Guillo
Post date: 7/21/2009 5:43:09 AM

RE: Using AddFiniteExtrudedProtrusion in VBScript

[ Edited ]

 

Is there any other way to create a basic 3D object using VBScript?  I would like to create box and cylinder of specified size and material.  I use Circles2d.AddByCenterRadius for cylinder but still fail at AddFiniteExtrudedProtusion.

Thanks

 

Posted by: Pascal Boivin
Post date: 7/21/2009 8:26:15 AM

RE: Using AddFiniteExtrudedProtrusion in VBScript

[ Edited ]

I will lokk at this anytime this week, but i was wondering:

If your objective is to create a new file with a simple form inside (cylinder, box, etc) with certain dimensions,

why don't you just create some templates by hand and open one or another by programming and change some variables also via vbscript?

This is much more flexible, easy and allows you to create new parametric files with any form (complicated or not).

If that is not your objective, just ignore my comment.

Regards,

Julian

 

Posted by: Julian Guillo
Post date: 7/22/2009 5:29:14 AM

RE: Using AddFiniteExtrudedProtrusion in VBScript

[ Edited ]

 

I've done some template as you suggest to be able to continu my script.  But I still need to find a way to create new 3D part because I'll create complex part later.

 

Thanks for your help!

 

Posted by: Pascal Boivin
Post date: 7/24/2009 5:10:51 AM

RE: Using AddFiniteExtrudedProtrusion in VBScript

[ Edited ]

Pascal,

I don't know if i understood you well.

You want to create a new file from a template or you still want to cretae an empty file and construct things in it?

If case 1, you already have got a template (let's say it's "c:\template.par")

In this case:

my_template="c:\template.par"

'This should create a new part file as a copy of template.par. You will have to "save as" later

Set oSEDoc = oSEApp.Documents.Add("SolidEdge.PartDocument", my_template)

 

Posted by: Julian Guillo
Post date: 7/27/2009 5:09:18 AM

RE: Using AddFiniteExtrudedProtrusion in VBScript

[ Edited ]

I really want to create new part from nothing.

 

Posted by: Pascal Boivin
Post date: 7/27/2009 5:38:44 AM

RE: Using AddFiniteExtrudedProtrusion in VBScript

[ Edited ]

Pascal,

I tried it again but i didn't find any other solution.

Sorry i can't help you on this.

Any taker, any other idea?

 

Posted by: Julian Guillo
Post date: 7/27/2009 6:09:25 AM

Re: Using AddFiniteExtrudedProtrusion in VBScript

I don't know if there has been a solution to this problem, but I am having the same issue using Delphi 2010 (Object Pascal).