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: 

iLogic rule to change Title Blocks

21 REPLIES 21
SOLVED
Reply
Message 1 of 22
Anonymous
11118 Views, 21 Replies

iLogic rule to change Title Blocks

Hello,

 

I can't for some reason get this rule to work, simply want to be able to choose what title block to use.

I created a text parameter with the multi-values: TES ELE and TES EQU

I have 2 title blocks in my template called TES ELE and TES EQU

Here is my code, basically, I want to rule to apply the title block based on the selection, which will be done on a form.

If Title = "TES ELE" Then
ActiveSheet.TitleBlock = "TES ELE"

ElseIf Title = "TES EQU" Then
ActiveSheet.TitleBlock = "TES EQU"

End If

InventorVb.DocumentUpdate()

ThisApplication.ActiveView.Fit

 I have found many threads in this forum and have used their solutions for this rule, but for some reason, my rule will not select the title block and place it in the drawing.

Here is a snap of my set-up and my template file is attached

title block.png

 

 

Thanks!

21 REPLIES 21
Message 2 of 22
mikejones
in reply to: Anonymous

Hi Sean

 

You need to specify the parameter call

 

If Parameter ("Title") = "TES ELE" Then
ActiveSheet.TitleBlock = "TES ELE"

ElseIf Parameter ("Title") = "TES EQU" Then
ActiveSheet.TitleBlock = "TES EQU"

End If

InventorVb.DocumentUpdate()

ThisApplication.ActiveView.Fit

 

Mike

 

Autodesk Certified Professional
Message 3 of 22
Anonymous
in reply to: mikejones

Hey Mike, I tried this as well and I still get errors when trying to run the rule??

error-title1.png

 

error-title2.png

 

I used this code and there is properly named title blocks in my drawing template and a text parameter with the matching values as well.

 

If Parameter ("Title") = "TES ELE - A" Then
ActiveSheet.TitleBlock = "TES ELE - A"

ElseIf Parameter ("Title") = "TES ELE - B" Then
ActiveSheet.TitleBlock = "TES ELE - B"

ElseIf Parameter ("Title") = "TES EQU - A" Then
ActiveSheet.TitleBlock = "TES EQU - A"

ElseIf Parameter ("Title") = "TES EQU - B" Then
ActiveSheet.TitleBlock = "TES EQU - B"

End If

InventorVb.DocumentUpdate()

ThisApplication.ActiveView.Fit

 template.png

 

I don't understand, haha, why won't the rule display the selected title block?

 

Thanks!!

Message 4 of 22
mikejones
in reply to: Anonymous

Sean

 

Does your title block contain prompted entries by any chance?

 

Mike

Autodesk Certified Professional
Message 5 of 22
Anonymous
in reply to: mikejones

Yes!!?? There is one instance, but if that is an issue, I can rid of it...

 

Thanks

Message 6 of 22
mikejones
in reply to: Anonymous

Sean there is a different call for tilte blocks which contain prompted entries

ActiveSheet.SetTitleBlock("Other Title Block", "promptedEntry1", "promptedEntry2")

 

Mike

Autodesk Certified Professional
Message 7 of 22
Anonymous
in reply to: mikejones

Hey Mike,

 

I just got rid of the prompted entry and used the comments iproperty in the model to insert the info that i need.

 

That being done, the rule didn't work, but there was no errors, so I changed the rule code back to this:

If Title = "TES ELE - A" Then
ActiveSheet.TitleBlock = "TES ELE - A"

ElseIf Title = "TES ELE - B" Then
ActiveSheet.TitleBlock = "TES ELE - B"

ElseIf Title = "TES EQU - A" Then
ActiveSheet.TitleBlock = "TES EQU - A"

ElseIf Title = "TES EQU - B" Then
ActiveSheet.TitleBlock = "TES EQU - B"

End If

InventorVb.DocumentUpdate()

ThisApplication.ActiveView.Fit

 

and it now works.

 

I just need to create a rule now that will prompt my Form once the drawing template is opened and I can select my drawing sheet parameters: Units -> Sheet Size -> Company Title Block

 

Form.png

 

Thanks for your help Mike!!

 

 

Message 8 of 22
mrattray
in reply to: Anonymous

You just need to use a one liner rule (there is a snippet for it in the default snippets under forms). Then add this one liner rule to the event triggers under "New File".
Mike (not Matt) Rattray

Message 9 of 22
Anonymous
in reply to: mrattray

Hi,

I have a similar task: to choose one of two title blocks depending on a parameter entered in a form. My iLogic rule:

iLogicForm.Show("Drawing parameters")

If TitleBlock = "A" Then
ActiveSheet.TitleBlock = "TitleBlock A"
ElseIf TitleBlock = "B" Then
ActiveSheet.TitleBlock = "TitleBlock B"
End If

 

It works, but the problem is that I have to run the rule 2 times to change a title block. When I run the rule for the first time with changed parameter "TitleBlock" it doesn't change the title block. After second run it changes. Why this problem appears?

Message 10 of 22
Anonymous
in reply to: Anonymous

Yea I was kind of ignoring this issue, but or some reason, when you open your template, if the titleblock you want is the one that is already selected upon opening you have to pick the other titleblock then re-pick the initial titleblock, I don't know how to bypass this or this made sense.

 

In my example I have 4 different titleblock,

 

  • Elect A
  • Elect B
  • Equip A
  • Equip B

 

when I open the drawing template Elect A is first in the list(first by default)

 

If I want any of the other 3 titleblocks, the rule runs fine, but if I do in fact want Elect A to be the titleblock, it won't apply on the first run of the rule, I have to select one of the other 3, then apply, then re-select Elect A and press apply to get that titleblock.

 

The only solution I could think of was to create another blank parameter(titleblock), and make sure that one is selected first by default then if I want Elect A is would apply on first try..

 

 

Message 11 of 22
mrattray
in reply to: Anonymous

You're cheating. You need to have the LogicForm.Show line in a separate rule. The way it is currently written, the rule does not wait for user input before setting the title block.
So, to correctly configure this: You need two rules. One should contain only the show form line and should be listed under event triggers for new file. The second rule will contain the rest of the title block setting code and should be fired by a button embedded in your form. This will force the code to wait for user input before setting the title block.
If it doesn't make sense I can post some pictures.
Mike (not Matt) Rattray

Message 12 of 22
Anonymous
in reply to: mrattray

hmmm..I do have a separate rule for the form to show...I would upload my template but it is 2014, do you have that?

 

I created a short (30sec video) of what I mean,

  • in the video you will see that my titleblock Equipment B is the default upon opening the template
  • I can't use Equipment B off the getgo because the apply button is greyed out
  • But if i select a different titleblock, then re-select the Equipment B title block, the apply button becomes active, but even after pressing it, the Equipment B titleblock does not apply to the drawing sheet
  • I have to acutally apply a different titleblock to the drawing sheet, then go back to Equipment B and apply it,

This can be seen in the video uploaded in the link here: http://screencast.com/t/JrAwBrweOydv

 

This also wasn't a major concern, because I don't always create Equipment B drawings, (roughly 25% of the time) so if/when I do create an Equipment B drawing, I just use the work around as seen in the video, only takes a few seconds.

 

That being said, if there is a simple solution to this, I would apply it.

 

Thanks!

Message 13 of 22
mrattray
in reply to: Anonymous

2211285, Are your rules set up like I said? It was your post that really inspired my comment. Welcome to the forums, by the way.
Sean, I do have 2014 loaded. If you upload your template file I'll take a look.

P.S. It looks like 2211285 deleted the post I was replying to right as I was posting.
Mike (not Matt) Rattray

Message 14 of 22
Anonymous
in reply to: mrattray

Yea, he posted something saying were not talking about the same issue, I thought it was for some reason, anyways, here is my template file,

 

Thanks

Message 15 of 22
Anonymous
in reply to: mrattray

Thanks! I made a separate rule for the form and it works now. But the other problem appears - I want the form to disappear after pressing a button. How to implement this?

P.S. I've posted a message before reading your answers, but when I read your answer I removed my post. You are replying quite quick.

Message 16 of 22
mrattray
in reply to: Anonymous

In the form editor under the properties for the button is a drop down option for what to do when the button is clicked. You want : "Apply, then Run, then Close".
Mike (not Matt) Rattray

Message 17 of 22
Anonymous
in reply to: mrattray

Perfect! Thanks!

Message 18 of 22
mrattray
in reply to: Anonymous

I made some changes. See how this works. It is a similar problem to 2211285's.

 

Edit: Forgot to attach.

Mike (not Matt) Rattray

Message 19 of 22
Anonymous
in reply to: mrattray

Yup! that update button works much better than the apply button!


Thanks!!

 

Only thing left I would like to do is play with the images, not sure if you noticed by the template is 1.2MB with no views on it...

I know the template has a bunch of iLogic in it, but the images are not the best either. I deleted the images from the template completely and the size dropped to 500kb...I heard something rumored about using vector images instead of bmp, but I'll look into that another day.

 

For now this template has been working great!!

 

Thanks again Mike!

 

 

Message 20 of 22
mrattray
in reply to: Anonymous

I didn't notice the bloat, but I would definitely suspect embedded images before code. I've used files with way more iLogic than that and didn't experience any file bloat; it's just text, after all. Could you use an externally linked image instead of an embedded one?
Mike (not Matt) Rattray

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

Post to forums  

Autodesk Design & Make Report