Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
nico
in reply to: MechMachineMan

Cheers for the reply,

Object_A.Name inside the Constraints.Addmate() doesn't work and gives and error:

Unable to cast object of type 'System.String' to type 'Autodesk.iLogic.Types.ComponentArgument

But it's easily solved by first defining a string and then inputting that string

 

So far I've split it up into 3 seperate rules, since it's different uses

The Add a Part/Product Rule currently looks like this: (And works like a charm :))

 

Dim Item As String
Dim Item_Unique_ID As String
Dim Item_URL As String
Dim Item_Extensie As String

Dim Offerte_N As String
Dim Materiaal_N As String

Dim oAsmCompDef As AssemblyComponentDefinition
Dim oOccurrence As ComponentOccurrence

If Unique_ID = True Then
	Offerte_N = Offerte_Nummer
	Materiaal_N = Materiaal_Nummer
	Item_Unique_ID = Materiaal_N & " - "
Else
	Offerte_N = ""
	Materiaal_N = ""
	Item_Unique_ID = ""
End If

If Producten = "0000 - Testblok 1" Or Producten = "0000 - Testblok 2" Then
	Item = Product 
	Item_Extensie = ".ipt"
	Item_URL = "C:\$Working Folder\Designs\iLogic Testen\"
	'Item_URL = "C:\$Working Folder\Designs\" & Product & ".ipt"
Else
	Item = Producten & " Configurator" 
	Item_Extensie = ".iam"
	Item_URL = "C:\$Working Folder\Designs\iLogic Testen\"
	'Item_URL = "C:\$Working Folder\Designs\" & Producten & "\20. 3D Designs\" & Producten & " - Configurator.iam"
End If

	oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
	i=0

For Each oOccurrence In oAsmCompDef.Occurrences
	If Left( oOccurrence.Definition.Document.DisplayName,10 ) = Item Then
	   i=i+1
	   oOccurrence.Name = Item & " :"+ CStr(i)
	End If
Next

Dim oProduct = Components.Add(Item_Unique_ID & Item & " :" & (i + "1"), Item & Item_Extensie)
Dim sProduct As String
	sProduct = oProduct.Name

' Unique Product Save - ONLY Top Level with Parameters ! For full copy of all Parts use the Copy command !
	WorkspacePath = ThisDoc.WorkspacePath()
	WorkspacePathLength = Len(WorkspacePath)
	PathOnly = ThisDoc.Path
	DirectoryPath = Strings.Right(PathOnly, PathOnly.Length-WorkspacePathLength)

'Check for the New Save folder and create it if it does not exist
	If(Not System.IO.Directory.Exists(Item_URL)) Then
		System.IO.Directory.CreateDirectory(Item_URL)
	End If

Save = MessageBox.Show("Save This Product?", "Save Product?", MessageBoxButtons.YesNoCancel)

	If Save = vbYes Then
		part = Component.InventorComponent(sProduct)
		doc = ThisApplication.Documents.Open(part.Definition.Document.FullDocumentName, False)
		doc.SaveAs(Item_URL & Item_Unique_ID & Item  & ".iam" , True)
		'doc.Close()
	End If

 

Being able to loop trough and renumber the occurances of identical parts/assemblys is essential

However I also need to do this in my "Constraining Rule" but I can't find a command for this?

 

So final question on this topic, is there a command to run trough all the Relationships and look for an open "Mate" or "Flush" Occurance Number?