Autodrawing - iLogic

Autodrawing - iLogic

GKPByDesign
Advocate Advocate
811 Views
4 Replies
Message 1 of 5

Autodrawing - iLogic

GKPByDesign
Advocate
Advocate

Hey I need help with the following. 

 

- Run iLogic on an open Assembly/Part to create a new drawing with every part and subassembly to be placed on a drawing in order of filename

- Create front, side, plan and isometric drawing with a decent scale 1:20/1:10/1:50 etc

- No dimensions required and to just place a drawing

- Place a flat pattern if one is available, skip this step is there isn't a flat pattern (place flat pattern on same page?) 

 

Can this be done at all? 

0 Likes
812 Views
4 Replies
Replies (4)
Message 2 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support

@GKPByDesign ,

 

Hoping that suggestions in the below blog link may be helpful.

 

https://clintbrown.co.uk/2018/10/07/automatic-drawings-with-ilogic/

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 5

GKPByDesign
Advocate
Advocate

The code copied below from Clint is along the lines of what I want but I want to be able to take it further. 

 

Open assembly, 

 

cycles through every part and sub assembly, auto scales, or manually scale for every page, can this code be adapted to suit? 

'Check if this is a drawing file
Dim doc = ThisDoc.Document
If doc.DocumentType = kDrawingDocumentObject Then
GoTo DRAWINGcode :
End If

'In parts & asemblies - Write file name and path to temp text file
oWrite = System.IO.File.CreateText("C:\TEMP\part.txt")
oWrite.WriteLine(ThisDoc.PathAndFileName(True))
oWrite.Close()
oFilePather = ThisDoc.Path & "\"

'In parts & asemblies - Write new drawing name to temp text file
oWrite = System.IO.File.CreateText("C:\TEMP\partno.txt")
oWrite.WriteLine(oFilePather & iProperties.Value("Project", "Part Number") & ".dwg")
oWrite.Close()

'Read Drawing name from text file
oRead = System.IO.File.OpenText("C:\TEMP\partno.txt")
EntireFile1 = oRead.ReadLine()
oRead.Close()
oDrawingName = EntireFile1

'Copy the Template file > keep templates saved in your project workspace, you need a separate part and assembly template
If doc.DocumentType = kAssemblyDocumentObject Then
oCopyFiler = "C:\Users\Clint\Workspace\ASSEMBLY_TEMPLATE.dwg"
Else If doc.DocumentType = kPartDocumentObject Then
oCopyFiler = "C:\Users\Clint\Workspace\PART_TEMPLATE.dwg"
End If

' Check if drawing exists - If it does, opening existing drawing
If System.IO.File.Exists(oDrawingName & DWGType) Then
ThisDoc.Launch(oDrawingName & DWGType)
Return
End If

'Launch New drawing
Dim oNewFiler As String = EntireFile1
System.IO.File.Copy(oCopyFiler,oNewFiler,(True))
ThisDoc.Launch(oNewFiler)

DRAWINGcode :
On Error GoTo Exiter
'Check if we have replaced the reference and scaled the drawing already
oNumbero = Parameter("Opened")
Parameter("Opened") = oNumbero + 1
'MsgBox(Parameter("Opened"))
If Parameter("Opened") > 2 Then
Return
End If

'Read in File name - For reference
oRead = System.IO.File.OpenText("C:\TEMP\part.txt")
EntireFile = oRead.ReadLine()
oRead.Close()
oPartPath = EntireFile

'Replace Drawing Reference
doc = ThisDoc.Document
Dim oFileDesc As FileDescriptor
oFileDesc = doc.ReferencedFileDescriptors(1).DocumentDescriptor.ReferencedFileDescriptor
oFileDesc.ReplaceReference(oPartPath)
doc.Update()

'Read in new name for Drawing
oRead = System.IO.File.OpenText("C:\TEMP\partno.txt")
EntireFile1 = oRead.ReadLine()
oRead.Close()
oDrawingName = EntireFile1

'Save this drawing
ThisDoc.Save

'Scale the Drawing - Note your drawing views names("VIEW1")&("VIEW4") must match the template
On Error GoTo Exiter
oMyParameter = ThisDrawing.Document.Parameters.UserParameters
oParameter = oMyParameter.AddByValue("Scaler", "1:5", UnitsTypeEnum.kTextUnits)
MultiValue.SetList("Scaler","1:1", "1:2", "1:4", "1:5", "1:10", "1:20", "1:25", "1:50", "1:100")

Scaler = InputListBox("Set Drawing Scale", MultiValue.List("Scaler"), Scaler, Title := "Scale = " & ActiveSheet.View("VIEW1").ScaleString, ListName := "List")
ActiveSheet.View("VIEW1").ScaleString = Scaler
ActiveSheet.View("VIEW4").ScaleString = Scaler
Parameter.Param("Scaler").Delete

Exiter :
'Msgbox("Scale not Changed")
0 Likes
Message 4 of 5

chandra.shekar.g
Autodesk Support
Autodesk Support

@GKPByDesign,

 

Try below iLogic code to get all referenced documents in an Assembly.

 

Public Sub Main() 
    ' Get the active assembly. 
    Dim oAsmDoc As AssemblyDocument 
    oAsmDoc = ThisApplication.ActiveDocument
    ' Get all of the referenced documents. 
    Dim oRefDocs As DocumentsEnumerator 
    oRefDocs = oAsmDoc.AllReferencedDocuments 

    ' Iterate through the list of documents. 
    Dim oRefDoc As Document 
    For Each oRefDoc In oRefDocs 
        MsgBox( oRefDoc.FullDocumentName )
    Next 
End Sub

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 5 of 5

NachoShaw
Advisor
Advisor

I have been working on a plugin for a long time, just getting round to picking it up and finishing it. This plugin will

 

allow you to set positions for assembly, part, presentation files

option part rotation to force landscape parts

adds a flat pattern to a position you visually set (optional rotation)

allows you to choose the view style for each type

gives you a visual designer to help with positioning

set & forget template settings

create sets (in case you have different types of documentation needs)

will create a drawing for each part / assembly / presentation

choice between multi sheet & single sheet

add dims to all views

add view names & optional numbers to each view with a pre-selected style

optional ignore library parts

quick button to run off a full set, active sheet, assembly only, part only

categorized material sets (you can for example print off all sheet metal only)

optional content center fastener sheet

optional add part lists to assembly and / or presentation sheets

 

should be ready in about a month, just sorting out security on it 🙂

 

Nacho
Automation & Design Engineer

Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC

EESignature


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.