Placing CC Part with ilogic not working correctly

Placing CC Part with ilogic not working correctly

r_hoekstra
Contributor Contributor
229 Views
2 Replies
Message 1 of 3

Placing CC Part with ilogic not working correctly

r_hoekstra
Contributor
Contributor

Got an rule which is getting an number from the numberingscheme in vault. This number needs to be given to the Content Center part which the rule is placing. 

Now the rule creates an part but when running the rule again in the assembly it replaces also the part which is placed in the first pattern.. 

Even when im using a different thickness . 

 

Also sometimes it doesnt place the custom part in the project path but makes it an Content Center File

 

Im using below code.

 

 

Sub Main

	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
		MessageBox.Show("Only in  Assembly", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
		Return
	End If
		
		PartNumber = getFilenamesFromVaultNamingScheme("Sequential 2020", "", 1)
		setfile(PartNumber)
		Return
	
End Sub

 

 

 

To Get the numer im using this part:

 

 

Function getFilenamesFromVaultNamingScheme(RequiredSchemeName As String, RequiredSchemeString As String, numberOfNames As Integer)

	Dim Connection As VDF.Vault.Currency.Connections.Connection = edm.EdmSecurity.Instance.VaultConnection()
	Dim genNum As String = String.Empty

	If Not Connection Is Nothing Then
		Dim entityClassId = VDF.Vault.Currency.Entities.EntityClassIds.Files
		Dim numSchemes As ACW.NumSchm() = Connection.WebServiceManager.NumberingService.GetNumberingSchemes(entityClassId, Nothing) 'kanske inte nothing
		Dim requiredScheme As ACW.NumSchm = (From sch As ACW.NumSchm In numSchemes
		Where sch.Name = RequiredSchemeName
		Select sch).FirstOrDefault()

		Dim numGenArgs() As String = {RequiredSchemeString }

		genNum = Connection.WebServiceManager.DocumentService.GenerateFileNumber(requiredScheme.SchmID, numGenArgs)

		Return genNum

	Else
		MessageBox.Show("Vault didn't work", "Fail!", _
		MessageBoxButtons.OK, MessageBoxIcon.Error)
	End If
End Function

 

 

And to place the part im using this part:

 

 

 

Public Sub setfile(partnum As String)
	
	Components.ContentCenterLanguage = "en-US"
	
	Dim lWelds As Double
	lWelds = InputBox("Geef aantal langsnaden op?", "Aantal Langsnaded", "1")

	Dim Thickness As Double
	Thickness = InputBox("Geef plaat dikte op", "Plaat Dikte", "6")

	Dim Path As String = ThisDoc.Path
	Dim oCCPart As ManagedComponentOccurrence
	
	'Dim oCCPartName As String = "Start/Finish Plate " & Thickness & "mm (" & partnum & ".ipt"
	Dim oCCPartName As String = partnum & ".ipt"
	MessageBox.Show(oCCPartName, "Title")
	oCCPart = Components.AddContentCenterPart(oCCPartName,
	"PARTS:FIB SHELL SECTIONS",
	"Start Finish Plate (2x per LW)", '''place your profile here
	"20056248", ''' place initial component parameters here
	position := Nothing, grounded := True, visible := False, appearance := Nothing)

	testing = "Start/Finish Plate " & Thickness & "mm"
	Patterns.AddRectangular(testing, oCCPartName, lWelds, 0.2 mm, Nothing, "X Axis", columnNaturalDirection := True, rowCount := 2, rowOffset := 2 mm, rowEntityName := "Y Axis", rowNaturalDirection := True)
	
	Dim FE As String = partnum & ".ipt" '''file name
	Dim PFE As String = Path & "\" & FE
	
	
	Dim oAsm As AssemblyDocument = ThisApplication.ActiveDocument
	Dim oAsmComp As AssemblyComponentDefinition = oAsm.ComponentDefinition
	Dim oldPFE As String = oAsmComp.Occurrences.ItemByName(oCCPartName).ReferencedDocumentDescriptor.FullDocumentName
	
	If Dir(PFE) = "" Then
		
		Dim oDoc As Document = ThisApplication.Documents.Open(oldPFE, False)
		
		oDoc.SaveAs(PFE, False)
		oDoc.Close
		'Return
	End If
	
	
	Component.Replace(oCCPartName, PFE, False)
	'MessageBox.Show(oCCPartName, "Title")

	Parameter(oCCPartName, "Thickness") = Thickness
	iProperties.Value("Project", "Part Number") = partnum
	Return

End Sub

 

 

 

Does anyone know why it isn't working like i hope it does ??

 

 

0 Likes
230 Views
2 Replies
Replies (2)
Message 2 of 3

r_hoekstra
Contributor
Contributor

Updated first  post

0 Likes
Message 3 of 3

r_hoekstra
Contributor
Contributor

Updated the first post..

0 Likes