iLogic Rule: Renaming Sheet Name to Occurrence Name Not Working?

iLogic Rule: Renaming Sheet Name to Occurrence Name Not Working?

patrick.b7
Contributor Contributor
517 Views
1 Reply
Message 1 of 2

iLogic Rule: Renaming Sheet Name to Occurrence Name Not Working?

patrick.b7
Contributor
Contributor

Greetings,

 

I've recently been researching the functionality of iLogic on Inventor and have been piecing together some rules to assist in automating CAD processes for my company.

 

My latest attempts have involved the automatic creation of a drawing from an assembly, where the user is prompted whether a sheet should be added for each part/subassembly in the assembly. It has been working well thus far, yet I seem to have one issue that I cannot get around: renaming each sheet to the name of the assembly part.

 

My method (taken from another idea somewhere on these forums) was to iterate through each component occurrence in an assembly, and ask the user whether they want an extra sheet added for that part. I've weeded out the parts that don't need to be drawn up (e.g. McMaster hardware, visions system parts, etc.) by checking if the occurrence name contains the project name, as we use the naming template "ProjectName_PartName" to organize all parts in our system. I wanted to rename each sheet to the current iteration occurrence name, yet the sheet names remain unchanged when I try this method:

 

For Each oOcc In oLeafOccs 

If oOcc.BOMStructure = BOMStructureEnum.kNormalBOMStructure Then
		cnt = cnt + 1
	
	If oOcc.Name.Contains(ProjectName) = True Then
		
		PartNameLC = Mid(oOcc.Name, InStr(oOcc.Name, "_") + 1)
		PartNameUC = UCase(PartNameLC)
		
		SheetYesNo = MsgBox("Component/Subassembly: " & PartNameUC, vbYesNo, "Add a sheet for the following assembly component?")
		
		If SheetYesNo = vbYes Then
			
		oControlDef = oCommandMgr.ControlDefinitions.Item("DrawingNewSheetCtxCmd")  
		' Execute the command.
		oControlDef.Execute
		oSheet = oDrawingDoc.ActiveSheet
		oSheet.ExcludeFromPrinting = False
		oSheet.ExcludeFromCount = False
		oSheet.Activate
		oSheet.Name = PartNameUC

'Note that PartNameUC is the name of the occurrence in each iteration in uppercase letters (a.k.a. the component name). I know that the string oOcc.Name
is correctly being assigned to this variable through message box verification, but the sheet name refuses to change.

 I've tried many different things, such as directly assigning oSheet.Name=oOcc.Name as well as verifying the sheet name should change to the project name by adding oSheet.Name=ProjectName (which it did), but no luck with the occurrence name! Any help is much appreciated, thank you!

Patrick Barnes
Mechanical Design Engineer
Inventor Professional - Vault
0 Likes
Accepted solutions (1)
518 Views
1 Reply
Reply (1)
Message 2 of 2

omartin
Advocate
Advocate
Accepted solution

Hye Patrick, when renaming the sheet you have to remove special characters like the ":" you can use something like:

patrickPartNameUC = PartNameUC.Replace(":", "")

 

 

Was my reply Helpful ? send a Kudos or accept as solution
0 Likes