Insert sheet, change format of the sheet and copy one view from the first sheet

Insert sheet, change format of the sheet and copy one view from the first sheet

ThomasCassan
Enthusiast Enthusiast
1,877 Views
9 Replies
Message 1 of 10

Insert sheet, change format of the sheet and copy one view from the first sheet

ThomasCassan
Enthusiast
Enthusiast

Hi Folkes!!

 

your knowledge is amazing - so i hope you can help me!

 

we´ve decided to create a separate sheet for the part list. So I need an ilogic rule doing following:

create a new sheet (A4) (with the same frame and header as the first sheet)

copy the iso view (if possible - the first view is also ok) into the new sheet

and - if possible - create the part list and put it on the header - fixed on the upper right corner (but thats just a very very nice to have  🙂 )

If someone has an idea - it would be really great and helpful!!

 

thx

Cheers

TC

 

 

0 Likes
Accepted solutions (1)
1,878 Views
9 Replies
Replies (9)
Message 2 of 10

Sergio.D.Suárez
Mentor
Mentor

Here is an example of code that could help you.
First copy a sheet, in this case the first.
Then take the view of some sheet, in the case it is the second sheet.
Copy the view on the new created sheet.
Then place a partslist in the upper corner

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.Sheets(1)

oSheet.Activate
'Copy sheet drawing
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingNewSheetCtxCmd").Execute2(True)  

Dim NewSheet As Sheet = oDoc.Sheets(oDoc.Sheets.Count)' indicates the new sheet create
Dim SheetView As Sheet = oDoc.Sheets(2) ' indicates the sheet where the view to copy is

If SheetView.DrawingViews.Count > 0 Then
oView = SheetView.DrawingViews(1) ' Select view from item

    SheetView.Activate
    Call oView.CopyTo(NewSheet) ' Copy view from sheetview to newsheet
	
'--------------- Add PartsList
	Dim oDrawingView As DrawingView = NewSheet.DrawingViews(1)
	Dim oPartsList As PartsList
	Dim oBorder As Border  = NewSheet.Border

	xrev = oBorder.RangeBox.MaxPoint.X
	yrev = oBorder.RangeBox.MaxPoint.Y
	Dim oPlacementPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
	oPartsList = NewSheet.PartsLists.Add(oDrawingView, oPlacementPoint,46594)  'kFirstLevelComponents 46593 First level components _ kPartsOnly 46594 Parts only. _kStructured 46593 Structured first level components. _kStructuredAllLevels 46595 Structured all components. 
	'oPartsList.Sort("Column name")
	'oPartsList.Renumber
	oPartsList.Style.UpdateFromGlobal
	'oPartsList.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("")
	'oPartsList1.Style = oDrawingDoc.StylesManager.PartsListStyles.Item("Parts List (ISO)")

	InventorVb.DocumentUpdate()
	
End If

 I hope the code is useful for you. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 10

ThomasCassan
Enthusiast
Enthusiast

Hi Sergio

 

first i want to thank you for your damned fast reply!!  🙂

 

I tried your code - but there is an error message

 

Falscher Parameter. (Ausnahme von HRESULT: 0x80070057 (E_INVALIDARG))

System.ArgumentException: Falscher Parameter. (Ausnahme von HRESULT: 0x80070057 (E_INVALIDARG))
bei Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
bei Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
bei LmiRuleScript.Main()
bei Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
bei iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

I need to tell you that i am not a specialist for ilogic - but i  know how to handle it.

 

if you have an idea whats the problem - thx a lot

 

Cheers

Thomas

0 Likes
Message 4 of 10

Sergio.D.Suárez
Mentor
Mentor

Hi, have you corrected the number in red? indicates the page where the view you want to copy is located. You must change that number.
Please tell me if the ilogic rule returns error  in another place.
regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 5 of 10

ThomasCassan
Enthusiast
Enthusiast

Hi Sergio

 

after i copied the code again - it makes a 2nd sheet - thats perfect

but i need it in A4 and the name of the sheet should be "PartList"

and there is no part list placed on the sheet.

 

so thx again for your faboulos support!

cheers

Tom

0 Likes
Message 6 of 10

Sergio.D.Suárez
Mentor
Mentor

Hi Tom, little by little I understand, do you have the format of the sheets in A3 for example? and I guess you want the list to be on an A4 sheet different from the previous ones.
To place the partslist, you need a drawing view (or a file path that I think is not your case).
On which sheet is the drawing view that will be reference of your partslist?
I hope I can help you, regards!


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 7 of 10

ThomasCassan
Enthusiast
Enthusiast

Hi Sergio

 

i send you the idw-template - so you can test it on the original file.

yes - the main page (always sheet 1) is in 80% A3, but for the part list i need for 98% A4 portrait

the view is on the main sheet - and its not relevant which view you´ll use - i would say the first view will do the job.

but in the end it does not matter which view it is  🙂

 

thx in advance

 

TC

 

 

 

 

0 Likes
Message 8 of 10

Sergio.D.Suárez
Mentor
Mentor

I hope this can help you, I have given you a descriptive example in the video. surely there will be other alternative roads.
But this worked for me at the first test.

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.Sheets(1)
Dim oDrawingView As DrawingView = oSheet.DrawingViews(1)
'Copy sheet
oSheet.Activate
'Copy sheet drawing
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingNewSheetCtxCmd").Execute2(True)  
Dim NewSheet As Sheet = oDoc.Sheets(oDoc.Sheets.Count)' indicates the new sheet create
NewSheet.Name = "PartsList"
NewSheet.Orientation = 10243 'kLandscapePageOrientation = 10242_kPortraitPageOrientation = 10243
NewSheet.Activate
ActiveSheet.ChangeSize("A4", MoveBorderItems := True)

'--------------- Add PartsList
Dim oPartsList As PartsList
Dim oBorder As Border  = NewSheet.Border
xrev = oBorder.RangeBox.MaxPoint.X
yrev = oBorder.RangeBox.MaxPoint.Y

Dim oPlacementPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
oPartsList = NewSheet.PartsLists.Add(oDrawingView, oPlacementPoint,46594)  'kFirstLevelComponents 46593 First level components _ kPartsOnly 46594 Parts only. _kStructured 46593 Structured first level components. _kStructuredAllLevels 46595 Structured all components. 
InventorVb.DocumentUpdate()

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 9 of 10

ThomasCassan
Enthusiast
Enthusiast

Ey Sergio!!

 

you are amazing!!!!

 

the only thing thats missig is that the header is empty after execute the rule. So - is it possible to put in a copy rule also so the header willl be filled exatly?? then you will win the golden globe here at Forstners!!!!

 

thx a lot man!!!

 

Cheers

Thomas

0 Likes
Message 10 of 10

ThomasCassan
Enthusiast
Enthusiast
Accepted solution

Hi Folks

 

this is my final solution - and it works PERFECT!!! Thx to everyone who supporting me in that case!!

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.Sheets(1)
Dim oDrawingView As DrawingView = oSheet.DrawingViews(1)
'Copy sheet
oSheet.Activate
'Copy sheet drawing
ThisApplication.CommandManager.ControlDefinitions.Item("DrawingNewSheetCtxCmd").Execute2(True)  
Dim NewSheet As Sheet = oDoc.Sheets(oDoc.Sheets.Count)' indicates the new sheet create
NewSheet.Name = "PartsList"
NewSheet.Orientation = 10243 'kLandscapePageOrientation = 10242_kPortraitPageOrientation = 10243
NewSheet.Activate
ActiveSheet.ChangeSize("A4", MoveBorderItems := True)
'Copy first view
Dim odrawdoc As DrawingDocument
odrawdoc = ThisApplication.ActiveDocument
firstviewfirstsheet = odrawdoc.Sheets.Item(1).DrawingViews.Item(1)
odrawdoc.Sheets.Item(2).Activate
Call firstviewfirstsheet.CopyTo(odrawdoc.Sheets.Item(2))


'--------------- Add PartsList
Dim oPartsList As PartsList
Dim oBorder As Border  = NewSheet.Border
xrev = oBorder.RangeBox.MaxPoint.X
yrev = oBorder.RangeBox.MaxPoint.Y

Dim oPlacementPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
oPartsList = NewSheet.PartsLists.Add(oDrawingView, oPlacementPoint, 46593)  
'kFirstLevelComponents 46593 First level components _ kPartsOnly 46594 Parts only. _kStructured 46593 Structured first level components. _kStructuredAllLevels 46595 Structured all components. 
InventorVb.DocumentUpdate()

muchas gracias

 

yous TC

0 Likes