Change Sheet Format - iLogic

Change Sheet Format - iLogic

Anonymous
Not applicable
2,840 Views
13 Replies
Message 1 of 14

Change Sheet Format - iLogic

Anonymous
Not applicable

Hi,

 

I want to change the Sheet Format for the Active sheet. I have one iLogic code that adds a new sheet with the sheet format I want, but I want to change it so it doesn't add an sheet but changes the active sheet. 

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oFormat As SheetFormat
Try
oFormat = oDrawDoc.SheetFormats.Item("A4 Vertical")
Catch
MessageBox.Show("Error: the named sheet format might not exist.", "iLogic")
Return
End Try
Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.ChangeUsingSheetFormat(oFormat)
Accepted solutions (1)
2,841 Views
13 Replies
Replies (13)
Message 2 of 14

mdavis22569
Mentor
Mentor

So you want to change it say from A3 to A2 .... or A2 to A3 ...A1 to A2 ..etc?

 

Do you want to pick which one, or have a bunch of codes that change to what the code wants 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Message 3 of 14

Anonymous
Not applicable

I want to have one form with an combobox that allows me to select from the Sheet Formats that I have saved in the drawing.

That form would appear once I create an new Drawing. That way I can select the sheet format right from the beggining. 

 

I don't want only to change to A3 or A4. I want to change to the pre-configured sheet formats I saved:

 

Untitled.png

 

To do this, I created one Parameter with multi value and added all the names of the available Sheet Formats. 

 

Now I just want one rule that changes the Sheet to the Sheet Format selected. 

 

I'm not sure If I was clear...

 

0 Likes
Message 4 of 14

mdavis22569
Mentor
Mentor

You kind  of show what I was going to say ..

 

Why set up a rule when you have them there already ..

 

So you'll click the ilogic code, then run rule, pop up box comes up ..you scroll and click on the size you want 

 

 

But you have them set up in your drawing resources already, why had another step?

 

sheet size.JPG


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Message 5 of 14

mdavis22569
Mentor
Mentor

....

 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Message 6 of 14

Anonymous
Not applicable

I understand. But I have sheets with standard views pre-configured that I want to use.

Untitled.png

 

That way I already have the number of views, sheet size and sheet orientation all done in one step.

0 Likes
Message 7 of 14

mdavis22569
Mentor
Mentor

Ok ...

 

So this might change what you're asking then.

 

I can give/find you code to change the sheet. However it's going to pick the ones in the resources.

 

 

So my next question is: Are you looking for one that will change the sheet and then place view depending on how many you have pre-configured? 

 

 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Message 8 of 14

Anonymous
Not applicable

I'm only going to use the ones already in the resources. 

 

At this point I'm not worried about the views. Just want to create an new Drawing and have Inventor ask me what is the type of sheet that I want to create (only allow the ones already in the resources) and create an empty sheet with that type. 

 

The code I had does this, but always create another sheet. So, when I create the DWG it as 2 Sheets, 1st is empty, and the 2nd is the one I want. 

0 Likes
Message 9 of 14

mdavis22569
Mentor
Mentor

Can you share a blank Idw ... when I run the code I just get an error ... This sheet format .... but that's keyed in

 

 


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Message 10 of 14

Anonymous
Not applicable

Sorry. My bad. The code had one error.

Try this one:

'Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
'Set a reference to the sheet format
Dim oFormat As SheetFormat
Try
oFormat = oDrawDoc.SheetFormats.Item("A4 VERTICAL")
Catch
MessageBox.Show("Error: the named sheet format might not exist.", "iLogic")
Return
End Try
'Create a new sheet based on the sheet format using the specified model
Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat)

For this to work you need to have in Drawing Resources -> Sheets Format -> one named "A4 VERTICAL"

 

This code will add one sheet with that Format. But it will keep sheet no 1.  

0 Likes
Message 11 of 14

mdavis22569
Mentor
Mentor

2.JPGerror.JPG

tried a few ways ..

 

by now I could have just changed the sheet .. can you give one of yours to reference since I can't get it to run. Note I changed the A4 to just A4 when it didn't work with vertical (as I don't have that one) to just A3, A4 and others that I do have in  my resources

 

 

PS .. .most ilogic is on the customization forum ... 

 

http://forums.autodesk.com/t5/inventor-customization/bd-p/12


Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

---------
Mike Davis

EESignature

0 Likes
Message 12 of 14

Anonymous
Not applicable
Accepted solution

I made It!! I did what I was looking for. 

 

So, if you save the attached file to the templates, when you create an new DWG with this file, it will ask you what is the size of the sheet from the resources that you want. 

 

see the attached file and let me know what you think. From this point now, I can add to that form some other questions and have the users answer all of them right from the beggining and from those questions select the approriate Title block, sheet size, orientation, .... automatically. 

Message 13 of 14

Anonymous
Not applicable

Hi, I've tried this code and it works for me..is there a way to delete the Sheet 1 then? thanks!

 

Nevermind found out how to do it: here it is:

 

basically from a single part plate this drawing will create a 2D drawing of that part...still in progress of how to put the views 🙂

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 14502 StartFragment: 314 EndFragment: 14470 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

'Function CreateDrawing_PlaceViews (PartNumber As String, DrawingViewScale As Double, ViewsToPlace As String, AssemblyDrawing As Boolean, ByRef oBaseView As DrawingView, ByRef oView2 As DrawingView, ByRef oView3 As DrawingView, ByRef oView4 As DrawingView)

    Dim oDrawDoc As DrawingDocument
    Dim oPartDoc As Document
    Dim oSheet As Sheet
    Dim oTG As TransientGeometry
    Dim oPoint1 As Point2d
    Dim oPoint2 As Point2d
    Dim oPoint3 As Point2d
    
    Filename=ThisDoc.FileName(False)
    
    'If this is the Assembly View, then use this Document as reference and open Drawing Template
    'Otherwise use the given Part Number And invisibly open the part, Use the active drawing
    If AssemblyDrawing = True Then
        oPartDoc = ThisDoc.Document
        oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "C:/Vault_Work/PROJECTS/iLogic Parts-inprogress/iLogic Part Generators/Rectangular Transition Chute Generator/DrawingTemplate.idw", True)
    Else If AssemblyDrawing = False 
        oPartDocPath = ThisDoc.Path & "\" & Filename & ".ipt"
        oPartDoc = ThisApplication.Documents.Open(oPartDocPath, False)
        'oDrawDoc = ThisApplication.ActiveDocument 
        oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "K:\Mech\INVENTOR2016\Inventor Resources\Templates\RAUTE_2016.dwg", True)
    End If
    
'Set a reference to the sheet format
Dim oFormat As SheetFormat
Try
oFormat = oDrawDoc.SheetFormats.Item("A-SIZE SHEET")
Catch
MessageBox.Show("Error: the named sheet format might not exist.", "iLogic")
Return
End Try
'Create a new sheet based on the sheet format using the specified model'Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat)    

oSheetName = "Sheet:1"
oSheet = ThisApplication.ActiveDocument.Sheets.Item(oSheetName) 
oSheet.Delete

 

 

0 Likes
Message 14 of 14

donaldleigh
Advocate
Advocate

Hi

 

Any chance you still have this code. I cant open the drawing attached as we use V14.

 

Donald

0 Likes