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:Ā 

change active drawing standard with ilogic

14 REPLIES 14
SOLVED
Reply
Message 1 of 15
jletcher
2211 Views, 14 Replies

change active drawing standard with ilogic

I am trying to have one drawing with B size and E size sheets I am trying to get the border, title block and standard to change when the sheet format changes. I can get it to work when I run the rule but have hard time find information to just change when sheet format changes. And I can't find anything or I should say a sample of how to. I think I found the code just don't know how to make it work. Here is what I  have so far. Sorry for not knowing but there is really nothing I can find to help so I choose you.

 


SubMain()

IfActiveSheet.Size="E"Then
ActiveSheet.TitleBlock="G&T (E)"
ActiveSheet.Border="G&T Border (E)"

EndIf

IfActiveSheet.Size="B"Then
ActiveSheet.TitleBlock="G&T (B)"
ActiveSheet.Border="G&T Border (B)"

EndIf




DimodrawdocAsDrawingDocument
odrawdoc=ThisApplication.ActiveDocument
customPropertySet=odrawdoc.PropertySets.Item("Inventor User Defined Properties")
Fori=1Toodrawdoc.Sheets.Count
' Make sure the desired property exists
Try
     
prop=customPropertySet.Item("Scale")
Catch
     
' Assume error means not found
      customPropertySet.Add("", "Scale")
EndTry
Try
iProperties.Value("Custom", "Scale")=odrawdoc.sheets.item(i).DrawingViews.Item(1).ScaleString
Catch
EndTry
Nexti
iLogicVb.UpdateWhenDone=True



End Sub

Thanks for the help.

14 REPLIES 14
Message 2 of 15
MjDeck
in reply to: jletcher

Sorry, there is no way to trigger a rule to run when the sheet size changes.  However, you can make the rule run when you save the drawing.  To do this, use the Event Triggers command (under Manage -> iLogic).  Here's a screenshot:

RulesTriggered.png


Mike Deck
Software Developer
Autodesk, Inc.

Message 3 of 15
jletcher
in reply to: MjDeck

What about changing the active standard. If I change the drawing from E to B and run the rule is there a code I can put in to change the  active standard to B?

Message 4 of 15
MjDeck
in reply to: jletcher

Sorry, there's no way to trigger a rule by changing the active standard (under Tools -> Document Settings -> Standard).

Here's a possible workaround:  Create a user Text parameter in your drawing, and call it Standard or Size.  Use this parameter in the If statements in your rule.  Then when you change the parameter, it will trigger the rule and you can change the sheet size and title block and border.  With this method, you have to use the parameter to change your sheet size.


Mike Deck
Software Developer
Autodesk, Inc.

Message 5 of 15
jletcher
in reply to: MjDeck

Ok I must not be saying it right. I don't care if it has trigger to change it. I am fine with just right click and running the rule. What I can't find is the code to put in the rule to change the standard when I run the rule.

Message 6 of 15
MjDeck
in reply to: jletcher

OK, sorry.  When I read your previous post again, I can see that's what you meant.

Here's a rule (in the attached file SetActiveDrawingStandard.txt) to change the active drawing standard.  I tested it on Inventor 2012, and it should work on 2011.  It contains some string manipulation code to give you some leeway in specifying your standard name.  It is set up to use an Inventor parameter named Standard, but you could modify it to use a local variable that you define in your rule.

 Possible values for Standard can be:
 ANSI
ANSI-mm
ISO
DIN
etc.


Mike Deck
Software Developer
Autodesk, Inc.

Message 7 of 15
jletcher
in reply to: MjDeck

Thanks I will give it a try and let you know. I have to say sorry I have german, english grammar issues and may make things harder then they should be.

Message 8 of 15
jletcher
in reply to: MjDeck

Ok I was able to try But I don't understand What you have. Here is my code I have so far works great just need to add active style code but seem not to find the code needed. What you have I could not get it to work must not understand it.

 

 

'Pick Sheet Size Sheet_Size= InputListBox("Select Sheet Size", MultiValue.List("Sheet_Size"), Sheet_Size, Title := "Sheet Size", ListName := "Choose Sheet Size")

'A size

 If Sheet_Size = "A (8 1/2 X 11)" Then

ActiveSheet.ChangeSize("A", MoveBorderItems := True)

ActiveSheet.TitleBlock = "Uni Pak A" ActiveSheet.Border = "Uni Pak A"

 

'B size

 ElseIf Sheet_Size = "B (11 X 17)" Then

ActiveSheet.ChangeSize("B", MoveBorderItems := True)

ActiveSheet.TitleBlock = "Uni Pak B" ActiveSheet.Border = "Uni Pak B"

 

'C size

ElseIf Sheet_Size = "C (17 X 22)" Then ActiveSheet.ChangeSize("C", MoveBorderItems := True) ActiveSheet.TitleBlock = "Uni Pak C"

ActiveSheet.Border = "Uni Pak C"

 

'D size

ElseIf Sheet_Size = "D (22 X 34)" Then ActiveSheet.ChangeSize("D", MoveBorderItems := True) ActiveSheet.TitleBlock = "Uni Pak D"

ActiveSheet.Border = "Uni Pak D"

 

'E size

ElseIf Sheet_Size = "E (34 X 44)" Then

ActiveSheet.ChangeSize("E", MoveBorderItems := True)

ActiveSheet.TitleBlock = "Uni Pak E" ActiveSheet.Border = "Uni Pak E"

 

End If

'update all iLogicVb.UpdateWhenDone = True

'zoom all ThisApplication.ActiveView.Fit

 

If you need my drawing let me know

 

Thanks

Message 9 of 15
jletcher
in reply to: jletcher

Also is there a way to have the ilogic list box come up after the new template opens?

Message 10 of 15
MjDeck
in reply to: jletcher

Here's a version that combines your latest rule with my code for selecting the drawing standard.
You could say that the drawing standard code is a bit complicated.  I did it that way to allow for shorter strings in the text parameter.  It makes the rule easier to use, although the code is more complicated. If it doesn't work in your drawing, please post your drawing file.  You might be using different drawing standards.

To make the rule run when you create a new drawing from the template, use the Event Triggers command (under Manage -> iLogic).  Add the rule to the New Document event.

NewDrawingOptions.png


Mike Deck
Software Developer
Autodesk, Inc.

Message 11 of 15
MjDeck
in reply to: MjDeck

Are you using a custom standard for each sheet size?  In a previous post, you mentioned a standard named B.  Do you have a separate standard for each sheet size, and every time you select a different sheet size you want to select the  standard for that particular sheet size?
Please post your template drawing.


Mike Deck
Software Developer
Autodesk, Inc.

Message 12 of 15
jletcher
in reply to: MjDeck

Yes, there is a standard for each size  drawing size here is my template.

Message 13 of 15
jletcher
in reply to: MjDeck

Yes to give more information.

 

If I pick A (8 1/2 X 11) the standard would change to Uni Pak A

If I pick B (11 X 17)  the standard would change to Uni Pak B

If I pick C (22 X 34)  the standard would change to Uni Pak C,D

If I pick E ( 34 X 44)  the standard would change to Uni Pak E

 

Trying to get it where they don't forget to change the standards when they change the sheet size.

Message 14 of 15
MjDeck
in reply to: MjDeck

Here's a new version of your rule, with code added to select the standard.  The code is a lot simpler than what I posted before. 


Mike Deck
Software Developer
Autodesk, Inc.

Message 15 of 15
jletcher
in reply to: MjDeck

That is the best thing ever..............

 

 Thanks

 

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

Post to forums  

Autodesk Design & Make Report