monirri
Mechanical
- Feb 22, 2006
- 44
Hi. I started this thread thread562-148260
a months ago. I received an answer, i tried it, but didn`t work, because I don`t understand.
I created the first protrusion of a piece using the addFiniteExtrudedProtrusion method, and the following ones using ExtrudedProtrusion.AddFinite (from parallel Refplanes added).
I tried to make a mirror copy of the first three features, but when I include the first or base feature (the first extruded protrusion), the mirror copy fails, so I have to mirror copy the last two and finish the part adding manually in VB what would be the mirror copy of the base protrusion.
I did already check the Number of Features.
So what is going on?
The code is this
'This is an attempt to create a mirror copy of
'a part having 3 protrusions. Each protrusions comes from
'a circle2D concentric profile in a parallel plane.
'The finished part looks like a gym dumbbell.
'This code isn´t working
Private Sub Command1_Click()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgePart.PartDocument
Const PI = 3.14159265358979
On Error Resume Next
Set objApp = GetObject(, "SolidEdge.Application")
If Err Then
Err.Clear
Set objApp = CreateObject("SolidEdge.Application")
If Err Then
MsgBox "Error: Solid Edge must be installed"
Err.Clear
End If
Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")
objApp.Visible = True
Else
Set objDoc = objApp.ActiveDocument
End If
'WINDOW MANAGING
objApp.Visible = True
objApp.Top = 0
objApp.Left = 0
objApp.Width = Screen.Width
objApp.Height = Screen.Height
objApp.WindowState = 2
'*************************
'CODE TO SHOW COMMANDBARS (Partfeatures AND MainToolBar)
Dim objEnv As SolidEdgeFramework.Environment
Dim objbar As SolidEdgeFramework.CommandBar
Dim counter As Integer
counter = 0
Set objEnv = objApp.Environments("Part")
For Each objbar In objEnv.CommandBars
objbar.Visible = True
counter = counter + 1
If counter = 2 Then
Exit For
End If
Next objbar
'*************************
'...Profiles
Dim Profile1 As SolidEdgePart.Profile
Dim Profile2 As SolidEdgePart.Profile
Dim Profile3 As SolidEdgePart.Profile
'...Profile Arrays
Dim ProfileArray(1 To 3) As SolidEdgePart.Profile
'...Solid Edge Reference planes
Dim ReferencePlanes As SolidEdgePart.RefPlanes
'...Planos de referencia individuales de Solid Edge
Dim PlaneXZ As SolidEdgePart.RefPlane
Dim PlaneYZ As SolidEdgePart.RefPlane
Dim PlaneXY As SolidEdgePart.RefPlane
'...Parallel planes
Dim ParallelPlane(1 To 4) As SolidEdgePart.RefPlane
Dim MirrorPlane As SolidEdgePart.RefPlane
Dim BaseProtrusion As SolidEdgePart.Model
Dim Protrusion2 As SolidEdgePart.ExtrudedProtrusion
Dim Protrusion3 As SolidEdgePart.ExtrudedProtrusion
Dim objMirr1 As SolidEdgePart.MirrorCopy
Dim objFtArr(1 To 3) As Object
Dim lngStatus As Long
'FIRST PROFILE
Set Profile1 = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:=objDoc.RefPlanes(3))
Call Profile1.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.1)
If lngStatus <> 0 Then
MsgBox "Profile for base protrusion is not closed"
End If
'FIRST PROTRUSION
Set ProfileArray(1) = Profile1
Set objModel = objDoc.Models
Set BaseProtrusion = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, _
ProfileArray:=ProfileArray, ProfilePlaneSide:=igLeft, _
ExtrusionDistance:=0.04) '<-------Method: addfiniteextrudedprotrusion
Profile1.Visible = False
Call objDoc.Windows(1).View.Fit
Set ReferencePlanes = objDoc.RefPlanes
Set PlaneXZ = ReferencePlanes.Item(3)
'CREATE PARALLEL PLANE FOR SECOND PROTRUSION
Set ParallelPlane(1) = ReferencePlanes.AddParallelByDistance(ParentPlane:=PlaneXZ, Distance:=0.04, _
NormalSide:=igLeft)
ParallelPlane(1).Visible = False
'SECOND PROFILE
Set Profile2 = objDoc.ProfileSets.Add.Profiles.Add(ParallelPlane(1))
Call Profile2.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.08)
If lngStatus <> 0 Then
MsgBox "Profile for base protrusion is not closed"
End If
Call objDoc.Windows(1).View.Fit
'SECOND PROTRUSION
Set Protrusion2 = BaseProtrusion.ExtrudedProtrusions.AddFinite(Profile:=Profile2, _
ProfileSide:=igLeft, ProfilePlaneSide:= _
igLeft, Depth:=0.04) '<-------Method: extrudedprotrusions.addfinite
Profile2.Visible = False
'CREATE PARALLEL PLANE FOR THIRD PROTRUSION
Set ParallelPlane(2) = ReferencePlanes.AddParallelByDistance(ParentPlane:=PlaneXZ, Distance:=0.08, _
NormalSide:=igLeft)
ParallelPlane(2).Visible = False
'THIRD PROFILE
Set Profile3 = objDoc.ProfileSets.Add.Profiles.Add(ParallelPlane(2))
Call Profile3.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.06)
If lngStatus <> 0 Then
MsgBox "Profile for base protrusion is not closed"
End If
Call objDoc.Windows(1).View.Fit
'THIRD PROTRUSION
Set Protrusion3 = BaseProtrusion.ExtrudedProtrusions.AddFinite(Profile:=Profile3, _
ProfileSide:=igLeft, ProfilePlaneSide:= _
igLeft, Depth:=0.04) '<-------Method: extrudedprotrusions.addfinite
Profile3.Visible = False
'CREATE THE MIRROR PLANE
Set MirrorPlane = ReferencePlanes.AddParallelByDistance(ParentPlane:=PlaneXZ, _
Distance:=0.12, NormalSide:=igLeft)
MirrorPlane.Visible = True
'CREATE FEATURES ARRAY FOR MIRROR COPY
Set objFtArr(1) = BaseProtrusion '<-----HERE IS THE PROBLEM
'if I introduce BaseProtrusion
'in the array, MirrorCopy fails
'If I put
'Set objFtArr(1) = Protrusion2
'Set objFtArr(2) = Protrusion3
'and
'NumberofFeatures:=2 then works
'but only 2 protrusions I need all 3
Set objFtArr(2) = Protrusion2
Set objFtArr(3) = Protrusion3
' Create the Mirror
Set objMirr1 = BaseProtrusion.MirrorCopies.Add(PatternPlane:=MirrorPlane, NumberOfFeatures:=3, FeatureArray:=objFtArr)
Call objDoc.Windows(1).View.Fit
'FIT SCREEN
Call objDoc.Windows(1).View.Fit
objDoc.RefPlanes.Item(1).Visible = False
objDoc.RefPlanes.Item(2).Visible = False
objDoc.RefPlanes.Item(3).Visible = False
DoEvents
End Sub
Thanks a lot
a months ago. I received an answer, i tried it, but didn`t work, because I don`t understand.
I created the first protrusion of a piece using the addFiniteExtrudedProtrusion method, and the following ones using ExtrudedProtrusion.AddFinite (from parallel Refplanes added).
I tried to make a mirror copy of the first three features, but when I include the first or base feature (the first extruded protrusion), the mirror copy fails, so I have to mirror copy the last two and finish the part adding manually in VB what would be the mirror copy of the base protrusion.
I did already check the Number of Features.
So what is going on?
The code is this
'This is an attempt to create a mirror copy of
'a part having 3 protrusions. Each protrusions comes from
'a circle2D concentric profile in a parallel plane.
'The finished part looks like a gym dumbbell.
'This code isn´t working
Private Sub Command1_Click()
Dim objApp As SolidEdgeFramework.Application
Dim objDoc As SolidEdgePart.PartDocument
Const PI = 3.14159265358979
On Error Resume Next
Set objApp = GetObject(, "SolidEdge.Application")
If Err Then
Err.Clear
Set objApp = CreateObject("SolidEdge.Application")
If Err Then
MsgBox "Error: Solid Edge must be installed"
Err.Clear
End If
Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")
objApp.Visible = True
Else
Set objDoc = objApp.ActiveDocument
End If
'WINDOW MANAGING
objApp.Visible = True
objApp.Top = 0
objApp.Left = 0
objApp.Width = Screen.Width
objApp.Height = Screen.Height
objApp.WindowState = 2
'*************************
'CODE TO SHOW COMMANDBARS (Partfeatures AND MainToolBar)
Dim objEnv As SolidEdgeFramework.Environment
Dim objbar As SolidEdgeFramework.CommandBar
Dim counter As Integer
counter = 0
Set objEnv = objApp.Environments("Part")
For Each objbar In objEnv.CommandBars
objbar.Visible = True
counter = counter + 1
If counter = 2 Then
Exit For
End If
Next objbar
'*************************
'...Profiles
Dim Profile1 As SolidEdgePart.Profile
Dim Profile2 As SolidEdgePart.Profile
Dim Profile3 As SolidEdgePart.Profile
'...Profile Arrays
Dim ProfileArray(1 To 3) As SolidEdgePart.Profile
'...Solid Edge Reference planes
Dim ReferencePlanes As SolidEdgePart.RefPlanes
'...Planos de referencia individuales de Solid Edge
Dim PlaneXZ As SolidEdgePart.RefPlane
Dim PlaneYZ As SolidEdgePart.RefPlane
Dim PlaneXY As SolidEdgePart.RefPlane
'...Parallel planes
Dim ParallelPlane(1 To 4) As SolidEdgePart.RefPlane
Dim MirrorPlane As SolidEdgePart.RefPlane
Dim BaseProtrusion As SolidEdgePart.Model
Dim Protrusion2 As SolidEdgePart.ExtrudedProtrusion
Dim Protrusion3 As SolidEdgePart.ExtrudedProtrusion
Dim objMirr1 As SolidEdgePart.MirrorCopy
Dim objFtArr(1 To 3) As Object
Dim lngStatus As Long
'FIRST PROFILE
Set Profile1 = objDoc.ProfileSets.Add.Profiles.Add(pRefPlaneDisp:=objDoc.RefPlanes(3))
Call Profile1.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.1)
If lngStatus <> 0 Then
MsgBox "Profile for base protrusion is not closed"
End If
'FIRST PROTRUSION
Set ProfileArray(1) = Profile1
Set objModel = objDoc.Models
Set BaseProtrusion = objDoc.Models.AddFiniteExtrudedProtrusion(NumberOfProfiles:=1, _
ProfileArray:=ProfileArray, ProfilePlaneSide:=igLeft, _
ExtrusionDistance:=0.04) '<-------Method: addfiniteextrudedprotrusion
Profile1.Visible = False
Call objDoc.Windows(1).View.Fit
Set ReferencePlanes = objDoc.RefPlanes
Set PlaneXZ = ReferencePlanes.Item(3)
'CREATE PARALLEL PLANE FOR SECOND PROTRUSION
Set ParallelPlane(1) = ReferencePlanes.AddParallelByDistance(ParentPlane:=PlaneXZ, Distance:=0.04, _
NormalSide:=igLeft)
ParallelPlane(1).Visible = False
'SECOND PROFILE
Set Profile2 = objDoc.ProfileSets.Add.Profiles.Add(ParallelPlane(1))
Call Profile2.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.08)
If lngStatus <> 0 Then
MsgBox "Profile for base protrusion is not closed"
End If
Call objDoc.Windows(1).View.Fit
'SECOND PROTRUSION
Set Protrusion2 = BaseProtrusion.ExtrudedProtrusions.AddFinite(Profile:=Profile2, _
ProfileSide:=igLeft, ProfilePlaneSide:= _
igLeft, Depth:=0.04) '<-------Method: extrudedprotrusions.addfinite
Profile2.Visible = False
'CREATE PARALLEL PLANE FOR THIRD PROTRUSION
Set ParallelPlane(2) = ReferencePlanes.AddParallelByDistance(ParentPlane:=PlaneXZ, Distance:=0.08, _
NormalSide:=igLeft)
ParallelPlane(2).Visible = False
'THIRD PROFILE
Set Profile3 = objDoc.ProfileSets.Add.Profiles.Add(ParallelPlane(2))
Call Profile3.Circles2d.AddByCenterRadius(x:=0, y:=0, Radius:=0.06)
If lngStatus <> 0 Then
MsgBox "Profile for base protrusion is not closed"
End If
Call objDoc.Windows(1).View.Fit
'THIRD PROTRUSION
Set Protrusion3 = BaseProtrusion.ExtrudedProtrusions.AddFinite(Profile:=Profile3, _
ProfileSide:=igLeft, ProfilePlaneSide:= _
igLeft, Depth:=0.04) '<-------Method: extrudedprotrusions.addfinite
Profile3.Visible = False
'CREATE THE MIRROR PLANE
Set MirrorPlane = ReferencePlanes.AddParallelByDistance(ParentPlane:=PlaneXZ, _
Distance:=0.12, NormalSide:=igLeft)
MirrorPlane.Visible = True
'CREATE FEATURES ARRAY FOR MIRROR COPY
Set objFtArr(1) = BaseProtrusion '<-----HERE IS THE PROBLEM
'if I introduce BaseProtrusion
'in the array, MirrorCopy fails
'If I put
'Set objFtArr(1) = Protrusion2
'Set objFtArr(2) = Protrusion3
'and
'NumberofFeatures:=2 then works
'but only 2 protrusions I need all 3
Set objFtArr(2) = Protrusion2
Set objFtArr(3) = Protrusion3
' Create the Mirror
Set objMirr1 = BaseProtrusion.MirrorCopies.Add(PatternPlane:=MirrorPlane, NumberOfFeatures:=3, FeatureArray:=objFtArr)
Call objDoc.Windows(1).View.Fit
'FIT SCREEN
Call objDoc.Windows(1).View.Fit
objDoc.RefPlanes.Item(1).Visible = False
objDoc.RefPlanes.Item(2).Visible = False
objDoc.RefPlanes.Item(3).Visible = False
DoEvents
End Sub
Thanks a lot