Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hello All,
I have created a VB.API program for the customization of an assembly. In this i have used a UDF to create a set of Co-ordinate system which is driven through excel. But the problem what i am facing here is when the Co-ordinate get created using the UDF each time i have to manually choose the Reference Co-ordinate system. How can i make that a single selection process.
Below i am giving the codes, Please guide on this.
Public Function createHoleUDFInPart(ByVal placementModel As IpfcSolid, _
ByVal Name01 As String, _
ByVal csysName As String, _
ByVal Dim1 As Double, _
ByVal Dim2 As Double, _
ByVal Dim3 As Double, _
ByVal Dim4 As Double, _
ByVal Dim5 As Double, _
ByVal Dim6 As Double, _
ByVal aseemblycount As Integer) _
As IpfcFeatureGroup
Dim csys As IpfcCoordSystem = Nothing
Dim cSystems As IpfcModelItems
Dim i As Integer
Dim udfInstructions As IpfcUDFCustomCreateInstructions
Dim csysSelection As IpfcSelection
Dim csysReference As IpfcUDFReference
Dim references As CpfcUDFReferences
Dim variantDims As IpfcUDFVariantDimension
Dim variantDims2 As IpfcUDFVariantDimension
Dim variantDims3 As IpfcUDFVariantDimension
Dim variantDims4 As IpfcUDFVariantDimension
Dim variantDims5 As IpfcUDFVariantDimension
Dim variantDims6 As IpfcUDFVariantDimension
Dim Coname As String
Dim variantVals As IpfcUDFVariantValues
Dim group As IpfcFeatureGroup
Try
cSystems = placementModel.ListItems(EpfcModelItemType.EpfcITEM_COORD_SYS)
Coname = "ACS" + Convert.ToString(aseemblycount)
For i = 0 To cSystems.Count - 1
If (cSystems.Item(i).GetName.ToString = "ASM_CSYS") Then
csysName = "ASM_CSYS"
csys = cSystems.Item(i)
Exit For
End If
Next
If csys Is Nothing Then
Throw New Exception("Coordinate System not found in current Solid")
End If
udfInstructions = (New CCpfcUDFCustomCreateInstructions).Create("CSYS")
udfInstructions.DimDisplayType = EpfcUDFDimensionDisplayType.EpfcUDFDISPLAY_BLANK
csysSelection = (New CMpfcSelect).CreateModelItemSelection(csys, Nothing)
csysReference = (New CCpfcUDFReference).Create("Reference Coordinate System", csysSelection)
references = New CpfcUDFReferences
references.Set(0, csysReference)
udfInstructions.References = references
variantDims = (New CCpfcUDFVariantDimension).Create("d0", Dim1)
variantDims2 = (New CCpfcUDFVariantDimension).Create("d1", Dim2)
variantDims3 = (New CCpfcUDFVariantDimension).Create("d2", Dim3)
variantDims4 = (New CCpfcUDFVariantDimension).Create("d3", Dim4)
variantDims5 = (New CCpfcUDFVariantDimension).Create("d4", Dim5)
variantDims6 = (New CCpfcUDFVariantDimension).Create("d5", Dim6)
variantVals = New CpfcUDFVariantValues
variantVals.Set(0, variantDims)
variantVals.Set(1, variantDims2)
variantVals.Set(2, variantDims3)
variantVals.Set(3, variantDims4)
variantVals.Set(4, variantDims5)
variantVals.Set(5, variantDims6)
udfInstructions.VariantValues = variantVals
references.GetHashCode()
group = placementModel.CreateUDFGroup(udfInstructions)
Return group
Catch ex As Exception
MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)
Return Nothing
End Try
End Function
End Class
I am also trying to automate the placement of udf features. The problem is that I still have to select the references in the model even though I am passing them in as CpfcUDFReferences. Is there a proper example of how this works so the user does not have to select the references? Or is there a settting that needs to be triggered?
Thanks!
I believe I have found the solution to this problem. After the CreateModelItemSelection line I added a line highlighting the selection.
csysSelection = (New CMpfcSelect).CreateModelItemSelection(csys, Nothing) 'Existing line
csysSelection.Highlight(EpfcStdColor.EpfcCOLOR_SELECTED) 'Added line