ExtrudedProtrusion

 

Can anyone help me ?

I am trying to make Extruded Protrusion in VB.net. I have copyed the code from the example in the online help. it looks like i loose the profile when I try to extrude it. I thinke that the error is in the following line.

 

objModel = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, ProfileArray:=objEPProfArray(1), ProfilePlaneSide:=3, ExtrusionDistance:=0.1#)

Does anyone have an code example that works ?

AKO

 

Posted by: Anders ko
Post date: 12/17/2007 9:10:58 AM

19 REPLIES

RE: ExtrudedProtrusion

Hi,

Try this

objModel = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, ProfileArray:=objEPProfArray , ProfilePlaneSide:=3, ExtrusionDistance:=0.1)

 

Note: Use objEPProfArray instead of objEPProfArray(1)

 

 

Posted by: Prasad Pawar
Post date: 12/17/2007 5:21:08 PM

RE: ExtrudedProtrusion

 

Hi I am back in buissnes

It is stil not working

The profile is OK, if it set to visible = True, the cirkel appears on the screen, but not in the feature three

I have copyed the full code,

Dim objApp As SolidEdgeFramework.Application

Dim objDoc As SolidEdgePart.PartDocument

Dim objEPProfile As SolidEdgePart.Profile

Dim objEPProfArray As SolidEdgePart.Profile

Dim objModel As SolidEdgePart.Model

Dim objFromRP As SolidEdgePart.RefPlane

Dim objToRP As SolidEdgePart.RefPlane

Dim lngStatus As Long

        ' Report errors

        Const PI = 3.14159265358979

        ' Create/get the application with specific settings

        On Error Resume Next

        objApp = GetObject(, "SolidEdge.Application")

        If Err.Number = 0 Then

            Err.Clear()

            objApp = CreateObject("SolidEdge.Application")

            objDoc = objApp.Documents.Add("SolidEdge.PartDocument")

            objApp.Visible = True

        Else

            objDoc = objApp.ActiveDocument

        End If

        ' *** creating the base extruded protrusion feature symmetrically

        ' creating the profile and validating it

        objEPProfile = objDoc.ProfileSets.Add.Profiles.Add(RefPlaneDisp:=objDoc.RefPlanes.Item(1))

        Call objEPProfile.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.05)

        lngStatus = objEPProfile.End(ValidationCriteria:=1)

        If lngStatus 0 Then

            MsgBox("Profile for the base feature is not closed")

        End If

' creating the base extruded protrusion feature

' objEPProfArray = objEPProfile

objModel = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, ProfileArray:=objEPProfile, ProfilePlaneSide:=3, ExtrusionDistance:=0.1)

'Turn off the profile

objEPProfile.Visible = True

' USER DISPLAY

' Release objects

 objApp = Nothing

 objDoc = Nothing

 objEPProfile = Nothing

 objEPProfArray = Nothing

 objModel = Nothing

 objFromRP = Nothing

 objToRP = Nothing

 

Posted by: Anders ko
Post date: 2/19/2008 7:33:31 AM

RE: ExtrudedProtrusion

Im also having problems with extendProtrusions similar to this problem, would it easier to create a profile and Sketch view then create a protrusion?

 

Also if anyone just has some sample code of a simple ExtendProtrusion working i would be very happy

 

John Wong

 

Posted by: John Wong
Post date: 2/20/2008 1:42:38 PM

RE: ExtrudedProtrusion

Dear AKO & John,

This is a sample code (vb.net). It adds a sketch,gives it relation and extreude it. Hope this works for you people.

 

Dim objApp As SolidEdgeFramework.Application

Dim objDoc As SolidEdgePart.PartDocument

Dim objSketch As SolidEdgePart.Sketch

Dim objProfile(0 To 1) As SolidEdgePart.Profile

Dim objCircs As SolidEdgeFrameworkSupport.Circles2d

Dim objRelns As SolidEdgeFrameworkSupport.Relations2d

Dim objModel As SolidEdgePart.Model

 

Try

objApp = GetObject(, "SolidEdge.Application")

objApp.Visible = True

Catch ex As Exception

objApp = CreateObject("SolidEdge.Application")

objApp.Visible = True

End Try

objDoc = objApp.Documents.Add("SolidEdge.PartDocument")

objDoc = objApp.ActiveDocument

 

objSketch = objDoc.Sketches.Add

objProfile(0) = objSketch.Profiles.Add(pRefPlaneDisp:=objDoc.RefPlanes.Item(1))

objCircs = objProfile(0).Circles2d

Call objCircs.AddByCenterRadius(x:=0, y:=0, Radius:=0.05)

 

objRelns = objProfile(0).Relations2d

Call objRelns.AddFix(objCircs.Item(1))

 

objModel = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, _

ProfileArray:=objProfile, ProfilePlaneSide:=3, ExtrusionDistance:=0.1)

' Release objects

objApp = Nothing

objDoc = Nothing

objSketch = Nothing

objProfile = Nothing

objCircs = Nothing

objRelns = Nothing

objModel = Nothing

 

 

Posted by: Prasad Pawar
Post date: 2/20/2008 7:03:02 PM

RE: ExtrudedProtrusion

When you create profile, it will not visible in edge bar coz it is a part of the fearture. But when you add it as sketch, it will definitely visible in edgebar. Above example would clear it.

 

Posted by: Prasad Pawar
Post date: 2/20/2008 7:21:45 PM

RE: ExtrudedProtrusion

Thank you very much prasad for your example code unfornuatly when i tried to recreate your same code in VB6 i ran into some problems; so looking for more help i turned to the V15 programming guide and found myself even more confused

 

 

 

 

Public Class Form1

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'Declare the variables.

Dim objApp As Object

Dim objProfile As Object

Dim objProfileSets As Object

Dim objLines As Object

Dim igLineEnd As Int

Dim igLineStart As Int

Dim objRelations As Object

Dim objL(0 To 3) As Object

 

'Set a constant for the size of the square.

Const SIZE = 4 * 0.0254

 

'Connect to a running instance of Solid Edge.

objApp = GetObject(, "SolidEdge.Application")

 

'Determine the profile on which to draw.

objProfileSets = objApp.ActiveDocument.ActiveSketch

objProfile = objApp.ActiveDocument.ActiveSketch

 

'Set references to the collections used.

objLines = objProfile.Lines2d

objRelations = objProfile.Relations2d

 

'Draw the geometry.

objL(0) = objLines.AddBy2Points(0, 0, SIZE, 0)

objL(1) = objLines.AddBy2Points(SIZE, 0, SIZE, SIZE)

objL(2) = objLines.AddBy2Points(SIZE, SIZE, 0, SIZE)

objL(3) = objLines.AddBy2Points(0, SIZE, 0, 0)

 

'Add key point relationships between the ends of the lines.

Call objRelations.AddKeypoint(objL(0), igLineEnd, objL(1), igLineStart)

Call objRelations.AddKeypoint(objL(1), igLineEnd, objL(2), igLineStart)

Call objRelations.AddKeypoint(objL(2), igLineEnd, objL(3), igLineStart)

Call objRelations.AddKeypoint(objL(3), igLineEnd, objL(0), igLineStart)

 

'Create the feature.

Call objProfile.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, ProfileArray:=objProfile, ProfilePlaneSide:=3, ExtrusionDistance:=0.1)

 

End Sub

End Class

 

 

 

After a while of tinkering i tried this code which created a square for me, but when it tried to the key relationship points it would alter the look of the original shape(to a T shape). If i comment the key points out then the shape will be closed but it wont protrude, what do you think the problem is? (also are igLineEnd and igLineStart classes in Solid Edge because I intialized them as integers just so my program would compile, in the Programming Guide they were not intialized)

 

I hope my explained myself coheritly

Thanks in advance

 

 

John Wong

 

 

 

Posted by: John Wong
Post date: 2/21/2008 12:13:04 PM

RE: ExtrudedProtrusion

John,

Here is another snippet for you.

Instead of using objprofile, use objprifle(1 to 2) because input is an array.

Also in vb, index starts from 0 for object. So use ObjL(1 to 4)

Following code is working fine at my end. Hope it works at your place also.

If you have furhther queries, please mention them.

You can also mail me at prasad_1584@yahoo.co.in

 

 

Private Sub Command1_Click()

'Declare the variables.

Dim objApp As SolidEdgeFramework.Application

Dim objDoc As SolidEdgePart.PartDocument

Dim objProfiles As Object

Dim objProfile(1 To 2) As Object

Dim objProfileSets As Object

Dim objProfileSet As Object

Dim objLines As Object

Dim objRelns As Object

Dim objL(1 To 4) As Object

 

'Set a constant for the size of the square.

Const SIZE = 4 * 0.0254

 

' Create/get the application with specific settings

On Error Resume Next

Set objApp = GetObject(, "SolidEdge.Application")

Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")

If Err Then

Err.Clear

Set objApp = CreateObject("SolidEdge.Application")

Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")

objApp.Visible = True

Else

Set objDoc = objApp.ActiveDocument

End If

 

' Get ProfileSets collection

Set objProfileSets = objDoc.ProfileSets

' Add a ProfileSet

Set objProfileSet = objProfileSets.Add

' Get the Profiles collection

Set objProfiles = objProfileSet.Profiles

' Add the empty profile

Set objProfile(1) = objProfiles.Add(pRefPlaneDisp:=objDoc.RefPlanes(1))

' Get the Lines collection

Set objLines = objProfile(1).Lines2d

 

' Place the lines

Set objL(1) = objLines.AddBy2Points(0, 0, SIZE, 0)

Set objL(2) = objLines.AddBy2Points(SIZE, 0, SIZE, SIZE)

Set objL(3) = objLines.AddBy2Points(SIZE, SIZE, 0, SIZE)

Set objL(4) = objLines.AddBy2Points(0, SIZE, 0, 0)

' Define Relations among the Line objects to make the Profile closed

Set objRelns = objProfile(1).Relations2d

 

Call objRelns.AddKeypoint(Object1:=objLines(1), Index1:=1, Object2:=objLines(2), Index2:=0)

Call objRelns.AddKeypoint(Object1:=objLines(2), Index1:=1, Object2:=objLines(3), Index2:=0)

Call objRelns.AddKeypoint(Object1:=objLines(3), Index1:=1, Object2:=objLines(4), Index2:=0)

Call objRelns.AddKeypoint(Object1:=objLines(4), Index1:=1, Object2:=objLines(1), Index2:=0)

 

Call objDoc.Models.AddFiniteExtrudedProtrusion(1, objProfile, 2, 0.05)

objProfile(1).Visible = False

 

End Sub

 

Posted by: Prasad Pawar
Post date: 2/21/2008 5:46:45 PM

RE: ExtrudedProtrusion

Also igLineStart and igLineEnd are the members of KeypointIndexConstants Constant Set, so we have not to declare them. We can directly use them or refer the Constant set given in Programming with SolidEdge. igLineEnd = 0 & igLineStart = 1

 

 

 

 

Posted by: Prasad Pawar
Post date: 2/21/2008 5:51:54 PM

RE: ExtrudedProtrusion

 

Thanke you very much !

your code example solved my problem. Now I can get working on my project.

Regards

AKO

 

Posted by: Anders ko
Post date: 2/21/2008 6:57:48 PM