Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

automatic/manual scale update

20 REPLIES 20
SOLVED
Reply
Message 1 of 21
bengee5454
1978 Views, 20 Replies

automatic/manual scale update

At the moment I use a form to fill in my title block. This works well. I would have to manually type in the scale - which is not much of a hinderance if I'm honest!

 

Then I thought about automatically updating the scale to the view scale, and upon reading blogs/posts on this topic, I found a little ilogic code that works a treat.

 

but what if I dont want to automatically update the scale? if I want to leave the Scale as 'NTS'? is there an option of using the first view scale, or typing in a custom scale?  see image.

 

by clicking on Set Scale, the border updates to the model scale, but what i would like is for the user to be able to fill in NTS in the box below which will overwrite the Set Scale?

 

Hope this is clear!

Tags (2)
20 REPLIES 20
Message 2 of 21
fakeru
in reply to: bengee5454

I suppose your ilogic code uses a custom iproperty to fill the scale automatically. Then it's easy.

I would do it this way.

First create a true/false parameter "Manual_scale".

Create another rule that will suppress the rule (named Scale) which drives the scale in your title block. This can look like this:

 

auto = iLogicVb.Automation

If Manual_Scale = True Then
auto.GetRule(ThisDoc.Document, "Scale").IsActive = False
Else
auto.GetRule(ThisDoc.Document, "Scale").IsActive = True
End If

So once the "Manual_scale" is true, you can type your scale values.

In the form it should look like this:

Untitled.jpg

1.add the iproperty that shows the scale in the title block, in my case named "Scale".

2.add the true/false parameter "manual_scale". when you check it, the Scale line above becomes active and you can type the value you want. press done (or apply if you have it).

3.add rule scale. this is for when you return to automatic scale by unchecking the "manual_scale", you simply click the button and you scale gets updated and you can see this the form. this is not really required, it's more for see the effect immediately.

 

 

Regards

Alexandru

Autodesk Inventor 2015 Certified Professional
Message 3 of 21
bengee5454
in reply to: fakeru

Thanks for the response....

 

I have followed your post and tweaked Inventor as you described....unfortunately something is amiss.

 

I cannot get the scale to update. Also, the scale (when Manual_Scale is ticked) does not become inactive.

 

I fear that something may be conflicting with my rule, but surely a warning would have popped up.

 

I currently have a rule which sets the scale to the view scale

 

Dim odrawdoc As DrawingDocument
odrawdoc = ThisApplication.ActiveDocument
customPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties")
For i = 1 To odrawdoc.Sheets.Count
' Make sure the desired property exists
Try      prop = customPropertySet.Item("Scale" + Str(i))
Catch      ' Assume error means not found
      customPropertySet.Add("", "Scale" + Str(i))
End Try
Try
iProperties.Value("Custom", "Scale" + Str(i)) = odrawdoc.sheets.item(i).DrawingViews.Item(1).ScaleString
Catch
End Try
Next i
InventorVb.DocumentUpdate()

 

then I added in the rule you gave:

 

auto = iLogicVb.Automation

If Manual_Scale = True Then
auto.GetRule(ThisDoc.Document, "Scale").IsActive = False
Else
auto.GetRule(ThisDoc.Document, "Scale").IsActive = True
End If

 

I then changed my form so that it resembled the form you showed.

 

the toggle button doesn't do anything, have i missed something?

 

 

Message 4 of 21
fakeru
in reply to: bengee5454

Your code for scale seems to be ok and it uses a custom property which also good.

My code is a bit different though:

 

Dim oApp As Inventor.Application = ThisApplication
Dim thisIDW As DrawingDocument = oApp.ActiveDocument
Dim oSheet As Sheet = thisIDW.ActiveSheet

ActiveSheet=ThisDrawing.Sheet(oSheet.Name)

DrawingViewName=ThisApplication.ActiveDocument.ActiveSheet.DrawingViews.Item(1).Name
iProperties.Value("Custom", "Scale" ) = ActiveSheet.View(DrawingViewName).ScaleString

 When you select manual scale and you write your scale don't hit "Set scale" button, just click apply or done or anything else on the form.

To make the scale line active or inactive go the scale property in the form editor, select it and below you will see behavior, under that is Enabling Parameter Name, choose "Manual_scale" parameter. When "Manual_scale" is true, the scale line is active and reverse.

Untitled.jpg

 

 

 

But if you can, please attach the template file.

 

Regards

Autodesk Inventor 2015 Certified Professional
Message 5 of 21
bengee5454
in reply to: fakeru

Attached is the template file as requested.

 

I would be very grateful if could spare a few moments to see if you can get this to work.

 

Thanks.

Message 6 of 21
fakeru
in reply to: bengee5454

Hi

Check the attached template.

Few things to say from the start. Your rule that sets the scale automatically is working with each sheet scale separately. That means it creates for each sheet a new scale custom iproperty (Scale 1, Scale 2, Scale 3... etc). In your form you added an iproperty "Scale" which is not used by your title block. In your title block you have "Scale 1" and that's right.. So I just replaced "Scale" with "Scale 1" in the form. Be aware that when you add a new sheet, it will use the same title block and therefore it will have the same "Scale 1" from sheet 1. That might be a problem. Making a new title block for each sheet might solve the problem. 

Now for the form I changed the predefined buttons. When you have only "Done" button, changes take effect immediatelly, that helps to understand qucker what have you done. Otherwise you have to click "Apply" to see the scale line becoming active or inactive.

 

Hope that helps!

 

Regards

Alexandru

 

Autodesk Inventor 2015 Certified Professional
Message 7 of 21
bengee5454
in reply to: fakeru

Thank you Alexandru, unfortunately when i try to open the file you attached I get an error stating

 

Error in reading RSe stream

 

I have quickly googled it and it turns out that SP2 needs to be installed. I have check IV and am told that the product is up to date!

 

any idea how I can get around this????

Message 8 of 21
fakeru
in reply to: bengee5454

That's strange. I used Inventor 2015 SP0. Later I can check again.

But I remeber I also received some erros when I opened the file first time, but I could work further anyway.

 

I suggest you should try to modify your template like I described above. Feel free to ask any question if something is not clear.

Autodesk Inventor 2015 Certified Professional
Message 9 of 21
bengee5454
in reply to: fakeru

Good news, I did what you described and the form works!

 

one minor point, the Manual Scale  check box seems to be serving no point. I thought it was meant to grey out the manual scale box when not ticked.

 

is there a way to grey out the "Set Scale" button if Manual Scale is ticked and un-grey the box to manually enter scale? and when unticked to do the reverse?

 

I could just delete the check box and just have "Set Automatic Scale" button, then under it "Enter Manual Scale", guess that would work, but its not how I can see the form in my mind!

 

Thanks

 

Message 10 of 21
bengee5454
in reply to: bengee5454

I like the way the 'Done' button updates straight away, thank you for pointing that out.

 

but what if you want to exit the dialogue box without the changes you made taking effect, i.e. cancel the operation and all changes made? This is not possible with just having the Done command - correct me if i'm wrong. I suppose you could always simply use the undo command.

Message 11 of 21
fakeru
in reply to: bengee5454


@BEN.gee wrote:

Good news, I did what you described and the form works!

 

one minor point, the Manual Scale  check box seems to be serving no point. I thought it was meant to grey out the manual scale box when not ticked.

 

is there a way to grey out the "Set Scale" button if Manual Scale is ticked and un-grey the box to manually enter scale? and when unticked to do the reverse?

 

I could just delete the check box and just have "Set Automatic Scale" button, then under it "Enter Manual Scale", guess that would work, but its not how I can see the form in my mind!

 

Thanks

 


Manual Scale is controlling the Set Scale rule. So once is Manual Scale = True, then rule "Set Scale" is suppressed. If Manual Scale = False then the rule will be run and the scale will equal to base view scale.

If you have Manual Scale = False, but if you manage to change the scale manually, you will get the scale changed in title block, but as your rule "Set Scale" is still active, at one point it will run (at close, save, open, update document action), and then the scale is again driven the rule.

 

In fact yesterday I realized that the "Set scale" button is not really necesary in the form. Once you untick manual_scale, the scale is imediatelly updated by the rule, you don't need that button. This is happens if you add an extra line in the other ilogic rule:

auto = iLogicVb.Automation

If Manual_Scale = True Then
auto.GetRule(ThisDoc.Document, "Scale").IsActive = False
Else
auto.GetRule(ThisDoc.Document, "Scale").IsActive = True
iLogicVb.RunRule("Scale")
End If

 

Autodesk Inventor 2015 Certified Professional
Message 12 of 21
fakeru
in reply to: bengee5454

Check this simple template. Should be nor problem to open.

Insert a base view and try swicth between manual and automatic scale from the form.

Autodesk Inventor 2015 Certified Professional
Message 13 of 21
bengee5454
in reply to: fakeru

having got the template to more or less how I wanted it (and making the schoolboy error of not regularly saving), Inventor crashed!

 

....and now it doesnt work - i cant enter a manual scale!

 

Please please please can you have a quick look and tell me what I've not done? 

 

what does this bit of code do (if you hadn't gathered, I'm not very good at coding)

 

iLogicVb.RunRule("Scale")
Message 14 of 21
bengee5454
in reply to: bengee5454

i have it back now, thats a relief

 

i still would like to know what does this bit of code does.

 

do i need to add it? it seems to work without....

 

iLogicVb.RunRule("Scale")
Message 15 of 21
fakeru
in reply to: bengee5454

that line simply runs another rule (rule "Scale" in this case).

I always set my rules "Don't run automatically", because I like to control them, I set the moment when they should run. This can be done also by Event Triggers, itriggers and this line as well. I also like to run some rules via buttons only. It's your choice and you will see this with time, depending on how it behaves.

 

.

Autodesk Inventor 2015 Certified Professional
Message 16 of 21
bengee5454
in reply to: fakeru

Thanks for your help!

I'm happy with what I've got now

Message 17 of 21
bengee5454
in reply to: fakeru

One more thing just occured to me....is it possible to limit the number of characters in the iproperty 'Part Number' to 27?

 

would this have to be a new rule or could it be added to an existing one?

Message 18 of 21
fakeru
in reply to: bengee5454

Put this code intro a new rule

Dim Temp_Name As String
Dim Correct_Name As String

NR = Len(iProperties.Value("Project", "Part Number"))
Substract_Nr = NR - 27

Temp_Name = iProperties.Value("Project", "Part Number")
Correct_Name = Left(Temp_Name, Len(Temp_Name) - Substract_Nr)

If Len(iProperties.Value("Project", "Part Number"))>27 Then
MessageBox.Show("Part Number is longer than 27 characters" & vbCr & "It will be shortened to 27 characters", "Maximum Value Rule", MessageBoxButtons.OK, MessageBoxIcon.Error)
iProperties.Value("Project", "Part Number") = Correct_Name
End If

 

Make 2 user paramters, "NR" and "Substract_Nr", unitless.

Capture.JPG

 

Make sure to trigger this rule be event:

 

Untitled.jpg

 

When your Part Number exceeds 27 characters, a warning message will appear and the the part number  will be shortened to 27 from right to left, meaning it will keep the first 27 characters.

If your Part Number doesn't exceed 27 characters, nothing will happen.

 

You can edit the display message if you want.

 

I'm not that good at ilogic coding, in fact this is my first code made from end to start, but it works for me.

Let me know if it works for you.

Autodesk Inventor 2015 Certified Professional
Message 19 of 21
bengee5454
in reply to: fakeru

that works a treat, thank you once again.

 

I have been looking at your code and I can kind of follow it.....what does '& vbCr &' do?

 

I think it means (visual basic) carriage return, am I close to the mark?

 

& vbCr &

 

I notice on the IF statement the code ssays:

 

If name>27

Then display message

display correct part number

 

shouldnt there be another statement e.g. IF....THEN....ELSE....? Or is the statement about the correct part number automatically put in if the IF is not satisfied?

 

Please excuse my questions, I am merely trying to get an understanding of the code

 

Thank you

Message 20 of 21
fakeru
in reply to: bengee5454

"& vbCr &" makes a new line in message window. Delete it and you will see.

 

I don't see the necessity to put another statement in this case.

Like I said above, if your part number has 27 or less characters, it will stay unchanged.

We may improve the rule, by moving the line Correct_Name = Left(Temp_Name, Len(Temp_Name) - Substract_Nr) into If Then statement, above this line: iProperties.Value("Project", "Part Number") = Correct_Name. So this action also takes place only when the condition is accomplished.

 

So when I go to iproperties and make the part number longer than 27 characters and hit apply, immediately I receive the message:

Capture.JPG

 

I press OK, the close the iproperties windows, I hit update update under the manage tab. When I go back to iproperties, I see that the part number is 27characters long.

 

If you will struggling with this rule to run properly, attach it here.

 

 

 

 

Autodesk Inventor 2015 Certified Professional

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

Post to forums  

Autodesk Design & Make Report