Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Drawing - Changing size and border

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
CCarreiras
655 Views, 10 Replies

Drawing - Changing size and border

HI!

 

I made an iLogic to select sheet sizes and change the border accordingly.

This works well, except when I chose A0, it changes well, but then I can't change anymore to other sizes, it became stuck in the A0 size.

If I delete manually the border, it starts to work well again, until I select again A0 size.

The file is attached, can you help with some ideas?

tip: the rule can be started with the trigger button.

 

ccarreiras_0-1652800439465.png

 

CCarreiras

EESignature

10 REPLIES 10
Message 2 of 11
A.Acheson
in reply to: CCarreiras

@CCarreiras your using 2023 Inventor Version so may not be abled to be opened by all forum users. Is it possible to attach the rules controlling the templates? Likely it just failing to add an object because there is one there. It may need to be deleted first like you doing manually then replicate by code. This post here as some logic checking the titleblock and border then deleting before adding. 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 3 of 11
JelteDeJong
in reply to: CCarreiras

I noticed that when I change the size manually, there is also an error.

JelteDeJong_0-1652819370749.png

I don't think the problem is in your code but I expect a problem in the border. Anyway, there is a workaround/hack. you could delete the border before you change anything. something like this:

trigger=iTrigger0

SheetSZ = InputListBox("Sheets", MultiValue.List("SheetSZ"), SheetSZ, Title :="SHEETS", ListName := "Select sheet size")

ActiveSheet.Sheet.Border.Delete()
break
 If SheetSZ = "A3 Horizontal" Then
	ActiveSheet.ChangeSize("A3")
	ActiveSheet.Border = "A3_H"
	ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kLandscapePageOrientation

Else If SheetSZ = "A3 Vertical" Then
	ActiveSheet.ChangeSize("A3")
	ActiveSheet.Border = "A3_V"
	ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kPortraitPageOrientation

Else If SheetSZ = "A2 Horizontal" Then
	ActiveSheet.ChangeSize("A2")
	ActiveSheet.Border = "A2_H"
	ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kLandscapePageOrientation

Else If SheetSZ = "A1 Horizontal" Then
	ThisApplication.ActiveDocument.ActiveSheet.Orientation = kLandscapePageOrientation
	ActiveSheet.ChangeSize("A1")
	ActiveSheet.Border = "A1_H"

Else If SheetSZ = "A0 Horizontal" Then	
	ThisApplication.ActiveDocument.ActiveSheet.Orientation = kLandscapePageOrientation
	ActiveSheet.ChangeSize("A0")
	ActiveSheet.Border = "A0_H"
	
End If
ThisApplication.ActiveView.Fit

 

Jelte de Jong
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.

EESignature


Blog: hjalte.nl - github.com

Message 4 of 11
CCarreiras
in reply to: A.Acheson

The code is very simple... a guess is not a problem with the code, will be something else...

Anyway, the code:

trigger=iTrigger0

SheetSZ = InputListBox("Sheets", MultiValue.List("SheetSZ"), SheetSZ, Title :="SHEETS", ListName := "Select sheet size")

 If SheetSZ = "A3 Horizontal" Then
	ActiveSheet.ChangeSize("A3")
	ActiveSheet.Border = "A3_H"
	ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kLandscapePageOrientation

Else If SheetSZ = "A3 Vertical" Then
	ActiveSheet.ChangeSize("A3")
	ActiveSheet.Border = "A3_V"
	ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kPortraitPageOrientation

Else If SheetSZ = "A2 Horizontal" Then
	ActiveSheet.ChangeSize("A2")
	ActiveSheet.Border = "A2_H"
	ThisApplication.ActiveDocument.ActiveSheet.Orientation  = kLandscapePageOrientation

Else If SheetSZ = "A1 Horizontal" Then
	ThisApplication.ActiveDocument.ActiveSheet.Orientation = kLandscapePageOrientation
	ActiveSheet.ChangeSize("A1")
	ActiveSheet.Border = "A1_H"
	

Else If SheetSZ = "A0 Horizontal" Then
	ThisApplication.ActiveDocument.ActiveSheet.Orientation = kLandscapePageOrientation
	ActiveSheet.ChangeSize("A0")
	ActiveSheet.Border = "A0_H"
	
End If

ThisApplication.ActiveView.Fit
CCarreiras

EESignature

Message 5 of 11
JelteDeJong
in reply to: CCarreiras

I did have another look at your border and found the problem. if you delete the following dimension in the upper right corner of your border definition. Then it all works again.

JelteDeJong_0-1652902173360.png

 

 

Jelte de Jong
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.

EESignature


Blog: hjalte.nl - github.com

Message 6 of 11
CCarreiras
in reply to: JelteDeJong

@JelteDeJong, deleting the border at the beginning solved part of the problem.

 

I add the standard Border at the beginning to avoid the other issues and started to work well with no additional problems:

ActiveSheet.Border = "Default Border"
ActiveSheet.Sheet.Border.Delete()
break

Noobie Q:  what is the purpose of using the BREAK? (Since the code works with and without it) 

CCarreiras

EESignature

Message 7 of 11
CCarreiras
in reply to: JelteDeJong

@JelteDeJong, well you found the problem, deleting that dimension solved the problem, which is weird because it's a copy of the original system border...
The question is... how did you find that needle in the haystack 😅

Thank you!

CCarreiras

EESignature

Message 8 of 11
JelteDeJong
in reply to: CCarreiras

the "break" should not have been there but I forgot to clean up my code. I use visual studio to debug iLogic rules. The break command makes visual studio stop/break at that point. Anyway it's not a problem to remove the line (or if you like to keep it).  For more information check this:

https://modthemachine.typepad.com/my_weblog/2019/12/using-visual-studio-to-debug-ilogic-rules.html

Jelte de Jong
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.

EESignature


Blog: hjalte.nl - github.com

Message 9 of 11
JelteDeJong
in reply to: CCarreiras

I found it by repeatedly deleting portions of the border and testing if solved the problem. This way I could zoom in to the problem. It takes some time but it is effective. 😉

Jelte de Jong
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.

EESignature


Blog: hjalte.nl - github.com

Message 10 of 11
CCarreiras
in reply to: JelteDeJong

oooh man, thank you for your time!!

 

FYI... i deleted the dimension, and then i recreated it, and works nice.... well ... software...

CCarreiras

EESignature

Message 11 of 11

Thanks for the code! I'm new to iLogic, and I was able to use your DWG to learn how to implement it. I'm trying to get custom borders for each drawing size, and limit the number of clicks it takes to do so. Thank you for posting

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report