Creating rules that save parts/assemblies and updates/creates new drawings

Creating rules that save parts/assemblies and updates/creates new drawings

4thAxis
Contributor Contributor
252 Views
2 Replies
Message 1 of 3

Creating rules that save parts/assemblies and updates/creates new drawings

4thAxis
Contributor
Contributor

This is going to be really basic, but here goes.

 

I have a global form that creates basic models with a "multi-part" and I want to add rules that carry out these functions:

  • save copy - save a copy and be able to specify where to save it
  • create new drawing or even just updating an existing "master" drawing that can then Save Copy As to a new folder

in the screenshot below, I placed fake buttons in the form to give you an idea of what the goal is.

 

johnfontana77_0-1643834583882.png

 

even a just a link to a tutorial for this specific task would be much appreciated. I'm trying to search for information, but there is so much out there that I can't find exactly what I need and am getting overwhelmed.

 

I think I have all the needed files attached.

 

 

 

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

A.Acheson
Mentor
Mentor

Saving as is the easy bit, how you want the user to interact with the information is harder because of the choices available.

 

  1. Do you want just to input a new name in the same folder or do you want to use a windows file dialogue to browse to the location? You will find an input box snippet in the ilogic editor. 

    1. Document save as Here is a post that has various saving methods. You could simply supply the new fullfilename in string format to the save as snippet and start building from there.
    2. And here is another that deals also with the drawing.

This is the snippet you will need to perform a save as. 

ThisDoc.Document.SaveAs(”C\Temp\Newfilename…….”, True)

And you can further expand on this by supplying the directory path of the document your in then make up the new fullfilename as string then save as with this new string. 

 

DirectoryPath = ThisDoc.Path

New_Name = InputBox("Enter New File Name", "Save as", "Name")

Newfullfilename = DirectoryPath & “\” & New_Name & “.ipt” ThisDoc.Document.SaveAs(Newfullfilename, True)   

I would suggest also to look at the built in API help you can use key words to search and also find ready built samples albeit mainly in VBA code and not ilogic. 

Any questions ask away. Tutorials on these custom coding are few and far between so really diving into forum threads and the help manual is your best bet. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 3

dialunau
Advocate
Advocate

Hello, this should work for creating a new drawing and save it in the same folder as the part/assembly:

 

Sub NewDwg()
	Dim oAssyDoc As AssemblyDocument = ThisDoc.Document
'Dim oPartDoc As PartDocument = ThisDoc.Document Dim oPath As String = ThisDoc.Path & "\" & ThisDoc.FileName & ".idw" 'Set the fullpath and file name oTemplate = ThisApplication.Documents.Add(Inventor.DocumentTypeEnum.kDrawingDocumentObject, _ "C:\Users\Public\Documents\Autodesk\Inventor 2022\Templates\en-US\Standard.idw", True) 'Replace for your template file path Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(1) Dim oScale As Double = 1 Dim Pt_0 As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(50, 25) ' Set the point for your view Dim bView As DrawingView = oSheet.DrawingViews.AddBaseView(oAssyDoc, _ Pt_0, 1, kRightViewOrientation, kHiddenLineDrawingViewStyle) bView.Scale = oScale ThisDoc.Document.SaveAs(oPath, True) End Sub
0 Likes