iLogic Automatic Drawing view Scale Label

iLogic Automatic Drawing view Scale Label

jfildes
Enthusiast Enthusiast
5,403 Views
13 Replies
Message 1 of 14

iLogic Automatic Drawing view Scale Label

jfildes
Enthusiast
Enthusiast

I'm making some upgrades to our standard drawing template and one of the things I would like to do is reference an initial view scale but when there isn't an initial view have the scale read "None". I currently have a custom iProperty named "Scale" that is called in the title block. I'm aware of the Sheet Property <Initial View Scale> and I want to utilize that in my iLogic code. I've been scouring the internet and the help menus for how to reference this property but I just can't find it. Ideally i want the code to do something like this:

 

1) Check for Initial View Scale

2) Set iProperties.Value("Custom","Scale") = the Initial View Scale

3) If that value is nothing then Scale = "None"

 

Anyone have any idea how to call the Inital View Scale? Thanks for the help. 

0 Likes
Accepted solutions (1)
5,404 Views
13 Replies
Replies (13)
Message 2 of 14

Anonymous
Not applicable

See how you get on with this.

 

On Error Resume Next

'Define the open document
Dim openDoc As Document
openDoc = ThisApplication.ActiveDocument

'Look at the model file referenced in the open document
Dim docFile As Document
docFile = ThisDoc.ModelDocument

If ThisDoc.ModelDocument IsNot Nothing Then

Dim oNumView As DrawingView
Dim ViewCount As Integer
ViewCount = 0
Dim oSCale As Double


For Each oNumView In ThisApplication.ActiveDocument.ActiveSheet.DrawingViews
ViewCount = ViewCount +1
'gets the view factor for the first view on the sheet.
If Viewcount =1 Then

'the scale factor is given as a decimal value (eg 1:2 is 0.5 etc)
oScale = Round(oNumview.Scale, 2)
'You need to create a few more lines like this to get from your scale factor to the standard annotation
If oScale = 0.03 Then iProperties.Value("Custom", "Scale").Value = "1:30")
'MessageBox.Show(oScale, "Scale Factor")


End If

Next
Else
iProperties.Value("Custom", "Scale").Value = "None"
End If


 

0 Likes
Message 3 of 14

jfildes
Enthusiast
Enthusiast
On Error Resume Next

'Define the open document
Dim openDoc As Document
openDoc = ThisApplication.ActiveDocument

'Look at the model file referenced in the open document
Dim docFile As Document
docFile = ThisDoc.ModelDocument

If ThisDoc.ModelDocument IsNot Nothing Then

Dim oNumView As DrawingView
Dim ViewCount As Integer
ViewCount = 0
Dim oSCale As Double


For Each oNumView In ThisApplication.ActiveDocument.ActiveSheet.DrawingViews
ViewCount = ViewCount +1
'gets the view factor for the first view on the sheet.
If Viewcount =1 Then

'the scale factor is given as a decimal value (eg 1:2 is 0.5 etc)
oScale = Round(oNumview.Scale, 2)
'You need to create a few more lines like this to get from your scale factor to the standard annotation
	If oScale = 0.03 Then 
	iProperties.Value("Custom", "Scale")= "1:30"
	'MessageBox.Show(oScale, "Scale Factor")
	End If
End If
Next

Else
iProperties.Value("Custom", "Scale").Value = "None"
End If

SutherNe, thanks for the help. I had to clean up the code a bit as there were some missing End If statements and an extra '.Value' in there. For the most part it works but I would have to assign a scale and a standard notation if statement for all expected values. It seems like an easier way to go about this may be to get the scale string from the base view. Another limitation is that it seems that if you delete a base view that the value doesn't reset. Is there a work around for this? Maybe assigning an initial value of "None" to the scale parameter? I'll play around with it and see what I can find and update as I find something. I appreciate the help. 

0 Likes
Message 4 of 14

Anonymous
Not applicable
Accepted solution

Hiya,

 

having had more time to properly go through my (rather messy) code I've cleaned it all up as such:

 

Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet  = oDrawDoc.ActiveSheet
Dim oSheets As Sheets
Dim oView As DrawingView
Dim oViews As DrawingViews
Dim oScale As Double
Dim oViewCount As Integer = 0

If ThisDoc.ModelDocument IsNot Nothing Then
oViews = oSheet.DrawingViews
For Each oView In oViews
oViewCount = oViewCount +1

If oViewCount = 1 Then
MessageBox.Show(oView.ScaleString)
'iProperties.Value("Custom", "Scale").Value = oView.ScaleString
End If

Next

Else

'iProperties.Value("Custom", "Scale").Value = "None"
MessageBox.Show("None")
End If

 

I've given this one a quick spin and it will give you the scale annotation instead of the scale factor for first view in the tree, which usually is your base view.

If you delete that view it will return the value for the next view in the tree.

Message 5 of 14

jfildes
Enthusiast
Enthusiast

This works and is excatly what I was looking for! Thank you so much for the help!

0 Likes
Message 6 of 14

MrSmithtastic
Advocate
Advocate

Is there any way of this having a prompt for input but with it a choice to ignore the prompt and it populate with the initial view scale?

0 Likes
Message 7 of 14

MrSmithtastic
Advocate
Advocate

Edit:

 

Managed to do it.

 

Only thing is that it now updates the scale for every sheet on the drawing and that's a bit annoying.

 

Need to find a way to update each sheet individually.

 

Dim oDrawDoc As DrawingDocument = ThisDrawing.Document
Dim oSheet As Sheet  = oDrawDoc.ActiveSheet
Dim oSheets As Sheets
Dim oView As DrawingView
Dim oViews As DrawingViews
Dim oScale As Double
Dim oViewCount As Integer = 0

If ThisDoc.ModelDocument IsNot Nothing Then
oViews = oSheet.DrawingViews
For Each oView In oViews
oViewCount = oViewCount +1

If oViewCount = 1 Then
dwgScale = InputBox("Enter Sheet Scale", "Scale", "ignor")
If dwgScale = "ignor" Then
'iProperties.Value("Custom", "Scale") = oView.ScaleString
Else
'iProperties.Value("Custom", "Scale") = dwgScale
End If

Next

Else

'iProperties.Value("Custom", "Scale") = "None"
MessageBox.Show("None")
End If
0 Likes
Message 8 of 14

Anonymous
Not applicable

Do you know of any way to have this be able to read per view instead of only the first view on the page? I am looking to have a custom view tag per view on the page that has each view scale, view, and sheet. Also the standard at the company that I work for is to use  letters instead of numbers to represent views. Is there a way to make this code work with a letter instead of as an integer?

 

I have attached a photo to show what I am trying to achieve, all of the information is currently being manually entered. We had previously been able to get it to work with a custom add in but have since stopped using the add in due to other issues. I am unable to find the portion of the code that relates to this task and I am trying to start from scratch.

0 Likes
Message 9 of 14

MechMachineMan
Advisor
Advisor

Soooo are you sure you want to use iProperties, or would prompted entry suit your needs better?


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 10 of 14

Anonymous
Not applicable

I want to try to use custom IProperties or find access the view label properties to pull the information that is typed in when placing a view so that it will auto fill to my tag.

0 Likes
Message 11 of 14

MechMachineMan
Advisor
Advisor
hmm. View labels sound like the way to go in that case. however, your
custom symbols and iProps won't work well as you will need a separate
iProps for each view.

I would maybe put a littler more thought into it all if I were you.

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 12 of 14

Anonymous
Not applicable

I have attached a video of how we were able to have this work previously in 2015 but the add in that we had doesn't work in 2017. I am trying to reproduce the same result but I can't get access to the View label properties.

0 Likes
Message 13 of 14

MechMachineMan
Advisor
Advisor

Can you open up the sketched symbol definition and check if any of those are prompted entry, and then also open up the drawing iProperties and see if there is anything in the custom tab?


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 14 of 14

Anonymous
Not applicable

The view tag is a prompted entry that is then being filled out with the view identifier.

 

There is a custom IProperty for Item code which is being filled out per the drawing in a form.

 

Then there is a prompted entry field for Scale which is being populated with the View/Scale Label.

 

Last there is a prompted entry For the name which is being filled out by the view orientation.

 

The same concept also works when I place a section or a detail, a custom tag is attached and the information is filled out when I change the view that It is referring to.

 

These tags have a prompted entry of sheet that is filled out by whatever Sheet the view is placed onto.

0 Likes