rule to auto update and save drawing to pdf

rule to auto update and save drawing to pdf

mitoborecek
Enthusiast Enthusiast
1,635 Views
32 Replies
Message 1 of 33

rule to auto update and save drawing to pdf

mitoborecek
Enthusiast
Enthusiast

How to make/run rule in drawing .dwg after change all parapeters and autoremodel assemble .iam.

 

When run rule in drawing I need tu update drawing (take about 10-15 sec) and save as .pdf with name (some parameter in assemble)

0 Likes
1,636 Views
32 Replies
Replies (32)
Message 21 of 33

mitoborecek
Enthusiast
Enthusiast

It sounds good, but I change only one parameter in assembly using Forms - it changes everything I need (import sizes and setting from excel)

0 Likes
Message 22 of 33

lewiskam723
Observer
Observer

To auto-update and save a drawing to PDF after changing parameters and remodeling an assembly in Autodesk Inventor, create an iLogic rule. The rule should first update the .dwg file after the assembly (.iam) changes, then introduce a delay (10-15 seconds) to complete the update process. Finally, it saves the drawing as a PDF, naming the file using an assembly parameter.

0 Likes
Message 23 of 33

mitoborecek
Enthusiast
Enthusiast

I need change only one parameter evrey time in assembly, and after finish all changes what made this one parameter, need run rule in drawing (update + export to pdf)

0 Likes
Message 24 of 33

J-Camper
Advisor
Advisor

@mitoborecek,

You said you change the parameter with a form right?  You can create a button on the form that calls the rule.  That way you shouldn't have to close the form.

 

If you don't like that then try one of the options, to incorporate calling the second rule at the end of your assembly adjustment rule, that I mentioned previously.

0 Likes
Message 25 of 33

mitoborecek
Enthusiast
Enthusiast

This is good idea, I will try it

but sometime I have parameter with simbol - for example "/" and export to pdf ended with error.

How to edit code, to end with open window "save as", where I write name of pdf?

0 Likes
Message 26 of 33

J-Camper
Advisor
Advisor
Accepted solution

If you don't want to manually edit the name, you can remove any invalid characters from the Name Parameter before adding to the filename:

 

Function GetPDFFileName(dDoc As DrawingDocument) As String
	
	Dim FileName As String = System.IO.Path.GetDirectoryName(dDoc.FullFileName) & "\"
	
	Dim IssueIndex As String = "Missing Reference Assembly"
	
	If dDoc.ReferencedDocuments.Count > 0
	
		Dim aDoc As AssemblyDocument = TryCast(dDoc.ReferencedDocuments.Item(1), AssemblyDocument)
		If aDoc IsNot Nothing
			
			Try
				IssueIndex = aDoc.ComponentDefinition.Parameters.Item("Name").Value.ToString
			Catch
				IssueIndex = "Missing_Name_Parameter"
			End Try
			
		End If
	
	End If
	
    For Each c As Char In System.IO.Path.GetInvalidFileNameChars()
      IssueIndex = IssueIndex.Replace(c.ToString, "")
    Next
	
	If IssueIndex = String.Empty Then IssueIndex = "Trimmed_Full_Name_Parameter_Value"
	
	FileName = String.Format("{0}{1}{2}", FileName, IssueIndex, ".pdf").ToString
	
	Return FileName
	
End Function

Added lines 22-26 to the previous function post

 

0 Likes
Message 27 of 33

mitoborecek
Enthusiast
Enthusiast

This works perfect.

One last thing. Is there rule after save to pdf to change parameter in assembly . The parameter is text - list of names. Names are Allways different. Need to automating this all.

0 Likes
Message 28 of 33

J-Camper
Advisor
Advisor

I added a Sub call in the filename function:

Function GetPDFFileName(dDoc As DrawingDocument) As String
	
	Dim FileName As String = System.IO.Path.GetDirectoryName(dDoc.FullFileName) & "\"
	
	Dim IssueIndex As String = "Missing Reference Assembly"
	
	Dim aDoc As AssemblyDocument = Nothing
	
	If dDoc.ReferencedDocuments.Count > 0
	
		aDoc = TryCast(dDoc.ReferencedDocuments.Item(1), AssemblyDocument)
		If aDoc IsNot Nothing
			
			Try
				IssueIndex = aDoc.ComponentDefinition.Parameters.Item("Name").Value.ToString
			Catch
				IssueIndex = "Missing_Name_Parameter"
			End Try
			
		End If
	
	End If
	
    For Each c As Char In System.IO.Path.GetInvalidFileNameChars()
      IssueIndex = IssueIndex.Replace(c.ToString, "")
    Next
	
	If IssueIndex = String.Empty Then IssueIndex = "Trimmed_Full_Name_Parameter_Value"
	
	If aDoc IsNot Nothing Then LogNameInNames(aDoc, IssueIndex)
	
	FileName = String.Format("{0}{1}{2}", FileName, IssueIndex, ".pdf").ToString
	
	Return FileName
	
End Function

Sub LogNameInNames(aDoc As AssemblyDocument, NameToAdd As String)
	Dim ListParam As Inventor.Parameter 
	
	Try
		ListParam = aDoc.ComponentDefinition.Parameters.Item("Names")
	Catch
		ListParam = aDoc.ComponentDefinition.Parameters.UserParameters.AddByValue("Names", NameToAdd, UnitsTypeEnum.kTextUnits)
	End Try
	
	Dim CurrentList As IList = MultiValue.List(aDoc.DisplayName, "Names")
	If Not CurrentList.Contains(NameToAdd) Then CurrentList.Add(NameToAdd)
	MultiValue.List(aDoc.DisplayName, "Names") = CurrentList

End Sub

 

Change "Names" to whatever your list parameter name is.

0 Likes
Message 29 of 33

mitoborecek
Enthusiast
Enthusiast

parameter name didn´t change.

0 Likes
Message 30 of 33

J-Camper
Advisor
Advisor

It should adding an entry to the list parameter.  Did you want the list parameter's value to be the newest entry in the list?

0 Likes
Message 31 of 33

mitoborecek
Enthusiast
Enthusiast

I have list parameters imported from excel. I need to auto change this parameter from 1. To last value. And after change value from 1. To 2. Value - update drawing and export to pdf 

0 Likes
Message 32 of 33

J-Camper
Advisor
Advisor

I thought you already had a rule doing the assembly changes based on the excel file.  I feel like I'm not fully understanding the request.  Can you elaborate or post images/examples of what you are trying to automate?

Feel free to correct me if I'm wrong, but this feels like it is deviating from the initial forum post, and would benefit from a separate post.  If you do make a new post you can @ me to make sure I see it.

0 Likes
Message 33 of 33

mitoborecek
Enthusiast
Enthusiast

You are right. I made new post

Thank you very much

0 Likes