iLogic Update Variable from pop up text box

iLogic Update Variable from pop up text box

jmcdougalNLEN6
Participant Participant
77 Views
1 Reply
Message 1 of 2

iLogic Update Variable from pop up text box

jmcdougalNLEN6
Participant
Participant

Hi -

 

I am working on a project where I need to combine many dwg drawing files into one. Each file has a sheet named "Arch B:1" and I need to copy a variable amount of drawings into one main file. I currently have the below iLogic rule that I run in each file, a little cumbersome but it works good enough. The only issue is whenever I start on a new set of files I need to update the path to the drawing that the sheets are getting pasted to. I was doing it by just editing the rule for every new set and pasting in the new path, however I am going to be having someone else work with me on this and am trying to make this process a little smoother. 

 

My thought was to have a text box pop open that you can paste the path into and that updates the path. I dont love that it would have to happen every time you run the rule but I cant think of a better way. 


So open to other ways of achieving this or if someone can just help modify the code below to allow me to paste in from a text box

 

'get sheet from active drawing
Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("ARCH B:1")
'create new drawing

Dim Drawing2 As DrawingDocument = ThisApplication.Documents.ItemByName("C:\_Vault2_LS\Designs\ **PATH TO FILE**")
'copy sheet from active drawing to new drawing 
Sheet_1.Sheet.CopyTo(Drawing2)
0 Likes
78 Views
1 Reply
Reply (1)
Message 2 of 2

WCrihfield
Mentor
Mentor

Hi @jmcdougalNLEN6.  Likely the least invasive way to make that change would be to use a simple 'InputBox', like in the following example:

'get sheet from active drawing
Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("ARCH B:1")
'create new drawing
Dim sPath As String = InputBox("Enter Path To Collection Drawing", "Common Drawing Path", "C:\_Vault2_LS\Designs\")
Dim Drawing2 As DrawingDocument = ThisApplication.Documents.ItemByName(sPath)
'copy sheet from active drawing to new drawing 
Sheet_1.Sheet.CopyTo(Drawing2)

However, that is likely not going to be as convenient as it could be either, so, below is another option.  It looks withn the current visibly open documents for any drawings, and attempts to create a Dictionary of their DisplayName and the actual DrawingDocument object, in pairs.  Then prompts the user to pick one of the DisplayNames.  If something was selected, it will then get the DrawingDocument associated with that DisplayName, and uses that for the destination of the copied sheet.

'get sheet from active drawing
Dim Sheet_1 = ThisDrawing.Sheets.ItemByName("ARCH B:1")
'get all open drawings into a Dictionary of their DisplayName & DrawingDocument object pairs
Dim oVisiblyOpenDrawings As Dictionary(Of String, Inventor.DrawingDocument) = ThisApplication.Documents.VisibleDocuments.OfType(Of Inventor.DrawingDocument).ToDictionary(Function(d) d.DisplayName)
If oVisiblyOpenDrawings Is Nothing OrElse oVisiblyOpenDrawings.Count = 0 Then
	MsgBox("There were no visibly open drawings to choose from!", , "")
	Return
End If
'prompt user to select the DisplayName of the drawing they want to use
Dim sSelectedName As String = InputListBox("Select collection drawing name", oVisiblyOpenDrawings.Keys.ToList(), String.Empty)
'make sure something was selected...if not, then exit rule
If sSelectedName = String.Empty Then Return
'get the DrawingDocument associated with the selected DisplayName
Dim oSelectedDrawing As DrawingDocument = oVisiblyOpenDrawings.Item(sSelectedName)
'copy sheet from active drawing to new drawing 
Sheet_1.Sheet.CopyTo(oSelectedDrawing)

 Another option would be to present the user with an actual Inventor.FileDialog, where the user can navigate to the other drawing file, then select it that way.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes