biw01
Automotive
- Dec 31, 2011
- 152
I am trying to create a linked exterior using VB.NET code.Even though i provide my program with a selected body and a face to create the linked exterior , the selected face is not getting attached to the body using code.
Any reason why the face is not getting attached ?
PFB the code below
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
'Dim dPart As Part = s.Parts.WorkComponent
Dim bodies(0) As Body
bodies(0) = sBody
Dim comps(bodies.Length - 1) As Assemblies.Component
Dim xforms(bodies.Length - 1) As NXOpen.Tag
Dim body_tags(bodies.Length - 1) As NXOpen.Tag
Dim proto As NXObject
'MsgBox("running")
Try
For ii As Integer = 0 To bodies.Length - 1
If bodies(ii).IsOccurrence() Then
comps(ii) = bodies(ii).OwningComponent
proto = bodies(ii).Prototype
body_tags(ii) = proto.Tag
ufs.So.CreateXformAssyCtxt(comps(ii).Tag, _
comps(ii).Tag, NXOpen.Tag.Null, xforms(ii))
MsgBox("running1")
Else
comps(ii) = Nothing
body_tags(ii) = bodies(ii).Tag
xforms(ii) = NXOpen.Tag.Null
MsgBox("running2")
End If
Next
'MsgBox("running")
Dim directions(,) As Double = _
{{1, 0, 0}}
Dim n_faces As Integer = 1
Dim faces(0) As Tag
faces(0) = sTag
Dim comp_index() As Integer = Nothing
'comp_index(comp_index.Length - 1) = 1
'MsgBox("running")
'ufs.Modl.IdentifyExteriorUsingHl(bodies.Length, body_tags, _
' xforms, 6, directions, _
' 0.0254, _
' UFConstants.UF_LINKED_HL_RES_COARSE, n_faces, faces, comp_index)
'MsgBox("running")
'body_tags(0) = bodyTag
Dim extData As UFModl.LinkedExt
With extData
.at_timestamp = False
.bodies = body_tags
.delete_openings = True
.faces = faces
.group_results = UFConstants.UF_LINKED_EXT_GROUP_NONE
.mass_props = True
.num_bodies = bodies.Length
.num_faces = faces.Length
.xform_index = comp_index
.xforms = xforms
End With
'MsgBox("running")
Dim extFeat As NXOpen.Tag = Nothing
Dim mark As Session.UndoMarkId = s.SetUndoMark( _
Session.MarkVisibility.Visible, "Create Linked Exterior")
ufs.Modl.CreateLinkedExterior(extData, extFeat)
'MsgBox("running")
Dim n_groups As Integer
Dim groups() As NXOpen.Tag = Nothing
Dim n_subfeats As Integer
Dim subfeats() As NXOpen.Tag = Nothing
Dim mass_props(46) As Double
ufs.Modl.AskLinkedExterior(extFeat, extData, n_groups, groups, _
n_subfeats, subfeats, mass_props)
Dim bList As ArrayList = New ArrayList
Dim bTag As NXOpen.Tag
For ii As Integer = 0 To n_subfeats - 1
ufs.Modl.AskFeatBody(subfeats(ii), bTag)
bList.Add(bTag)
Next
MsgBox("done")
'Dim bTags() As NXOpen.Tag = bList.ToArray(GetType(NXOpen.Tag))
'ufs.Modl.DeleteBodyParms(bTags)
'ufs.Ps.ExportData(bTags, "C:\temp\export_test.x_t")
Catch ex As Exception
MsgBox(ex.StackTrace + Chr(13) + Chr(13) + Chr(13) + ex.Message)
End Try
End Sub
Any reason why the face is not getting attached ?
PFB the code below
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
'Dim dPart As Part = s.Parts.WorkComponent
Dim bodies(0) As Body
bodies(0) = sBody
Dim comps(bodies.Length - 1) As Assemblies.Component
Dim xforms(bodies.Length - 1) As NXOpen.Tag
Dim body_tags(bodies.Length - 1) As NXOpen.Tag
Dim proto As NXObject
'MsgBox("running")
Try
For ii As Integer = 0 To bodies.Length - 1
If bodies(ii).IsOccurrence() Then
comps(ii) = bodies(ii).OwningComponent
proto = bodies(ii).Prototype
body_tags(ii) = proto.Tag
ufs.So.CreateXformAssyCtxt(comps(ii).Tag, _
comps(ii).Tag, NXOpen.Tag.Null, xforms(ii))
MsgBox("running1")
Else
comps(ii) = Nothing
body_tags(ii) = bodies(ii).Tag
xforms(ii) = NXOpen.Tag.Null
MsgBox("running2")
End If
Next
'MsgBox("running")
Dim directions(,) As Double = _
{{1, 0, 0}}
Dim n_faces As Integer = 1
Dim faces(0) As Tag
faces(0) = sTag
Dim comp_index() As Integer = Nothing
'comp_index(comp_index.Length - 1) = 1
'MsgBox("running")
'ufs.Modl.IdentifyExteriorUsingHl(bodies.Length, body_tags, _
' xforms, 6, directions, _
' 0.0254, _
' UFConstants.UF_LINKED_HL_RES_COARSE, n_faces, faces, comp_index)
'MsgBox("running")
'body_tags(0) = bodyTag
Dim extData As UFModl.LinkedExt
With extData
.at_timestamp = False
.bodies = body_tags
.delete_openings = True
.faces = faces
.group_results = UFConstants.UF_LINKED_EXT_GROUP_NONE
.mass_props = True
.num_bodies = bodies.Length
.num_faces = faces.Length
.xform_index = comp_index
.xforms = xforms
End With
'MsgBox("running")
Dim extFeat As NXOpen.Tag = Nothing
Dim mark As Session.UndoMarkId = s.SetUndoMark( _
Session.MarkVisibility.Visible, "Create Linked Exterior")
ufs.Modl.CreateLinkedExterior(extData, extFeat)
'MsgBox("running")
Dim n_groups As Integer
Dim groups() As NXOpen.Tag = Nothing
Dim n_subfeats As Integer
Dim subfeats() As NXOpen.Tag = Nothing
Dim mass_props(46) As Double
ufs.Modl.AskLinkedExterior(extFeat, extData, n_groups, groups, _
n_subfeats, subfeats, mass_props)
Dim bList As ArrayList = New ArrayList
Dim bTag As NXOpen.Tag
For ii As Integer = 0 To n_subfeats - 1
ufs.Modl.AskFeatBody(subfeats(ii), bTag)
bList.Add(bTag)
Next
MsgBox("done")
'Dim bTags() As NXOpen.Tag = bList.ToArray(GetType(NXOpen.Tag))
'ufs.Modl.DeleteBodyParms(bTags)
'ufs.Ps.ExportData(bTags, "C:\temp\export_test.x_t")
Catch ex As Exception
MsgBox(ex.StackTrace + Chr(13) + Chr(13) + Chr(13) + ex.Message)
End Try
End Sub