changing the scale of drawing view from 1/8 to 1 1/2" = 1'-0"

changing the scale of drawing view from 1/8 to 1 1/2" = 1'-0"

Anonymous
Not applicable
1,505 Views
4 Replies
Message 1 of 5

changing the scale of drawing view from 1/8 to 1 1/2" = 1'-0"

Anonymous
Not applicable

Hi,

 

I have this illogic that creates an A-size drawing and adds the drawing view for front view at the scale of 1/8 : 1.. I want that to read 1 1/2" = 1'-0" but cant get it to work.  Please help.

 

See attached illogic rules

 

1/8:1 and 1 1/2" = 1'-0" is basically the same thing so I keep on changing it to 1 1/2" = 1'-0" just because its the company's standard.

 

Thanks in advance!

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 40081 StartFragment: 314 EndFragment: 40049 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

'Function CreateDrawing_PlaceViews (PartNumber As String, DrawingViewScale As Double, ViewsToPlace As String, AssemblyDrawing As Boolean, ByRef oBaseView As DrawingView, ByRef oView2 As DrawingView, ByRef oView3 As DrawingView, ByRef oView4 As DrawingView)

Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum

    Dim oDrawDoc As DrawingDocument
    Dim oPartDoc As Document
    Dim oSheet As Sheet
    'Dim oDrawDoc As DrawingDocument = ThisDoc.Document
    Dim oDrawingView As DrawingView
    'Dim oSheet As Sheet = oDrawDoc.ActiveSheet
    Dim oPlacementPoint As Point2d
    Dim oBorder As Border
    Dim oPlaceX As Double
    Dim oPlaceY As Double
    Dim oPartsList As PartsList 
    Dim AssemblyDrawing As Boolean
    
    'Dim oTG As TransientGeometry
    'Dim oPoint1 As Point2d
    'Dim oPoint2 As Point2d
    'Dim oPoint3 As Point2d

    
    Filename = ThisDoc.FileName(False)
    

    'If this is the Assembly View, then use this Document as reference and open Drawing Template
    'Otherwise use the given Part Number And invisibly open the part, Use the active drawing
    'f AssemblyDrawing = True Then
        'oPartDoc = ThisDoc.Document
    DocType = ThisDoc.Document.DocumentType
    If DocType = DocumentTypeEnum.kAssemblyDocumentObject Then
        oPartDocPath = ThisDoc.Path & "\" & Filename & ".iam"
        oPartDoc = ThisApplication.Documents.Open(oPartDocPath, False)
        oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "K:\Mech\INVENTOR2016\Inventor Resources\Templates\RAUTE_2016.dwg", True)
        oPLS = oDrawDoc.StylesManager.PartsListStyles.Item("MULTIPLE-SINGLE PARTS LIST")
    'Else AssemblyDrawing = False 
    Else If DocType = DocumentTypeEnum.kPartDocumentObject Then
        oPartDocPath = ThisDoc.Path & "\" & Filename & ".ipt"
        oPartDoc = ThisApplication.Documents.Open(oPartDocPath, False)
    'DrawDoc = ThisApplication.ActiveDocument 
        oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "K:\Mech\INVENTOR2016\Inventor Resources\Templates\RAUTE_2016.dwg", True)
        oPLS = oDrawDoc.StylesManager.PartsListStyles.Item("SINGLE PART LIST")
    End If
    
'Set a reference to the sheet format
Dim oFormat As SheetFormat
Try
oFormat = oDrawDoc.SheetFormats.Item("A-SIZE SHEET")
Catch
MessageBox.Show("Error: the named sheet format might not exist.", "iLogic")
Return
End Try
'Create a new sheet based on the sheet format using the specified model'Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat)    

oSheetName = "Sheet:1"
oSheet1 = ThisApplication.ActiveDocument.Sheets.Item(oSheetName) 
oSheet1.Delete

'oSheet = oDrawDoc.Sheets.Item(1)

oTG = ThisApplication.TransientGeometry
    'Dim oTG As TransientGeometry'Set points in order to get wanted View (ie. if 'Y' is the same and 'X' is greater or less, you will get a Side View)
    oPoint1 = oTG.CreatePoint2d(13, 12)

Dim DrawingViewScale As Double


'Dim ViewScale2 As Double

 '   ViewScale1 = 1.0
  '  ViewScale2 = 5.0

  
'RoundToFraction(DrawingViewScale, 1/32, RoundingMethod.Round)    
DrawingViewScale = 1/8



'Create the Base View
oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint1, DrawingViewScale, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, "Master")
      
oBorder = oSheet.Border

oDrawingView = oSheet.DrawingViews(1)
oPlacementPoint = oBorder.RangeBox.MaxPoint
'oPlacementPoint = oBorder.RangeBox.MinPoint'oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(27,0)

'Create the parts list.    
Try
oPartList = oSheet.PartsLists(1)

Catch
oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint)   'oDrawingView'Set parts list To a specific layer
oPartsList.Layer = oDrawDoc.StylesManager.Layers.Item("Visible (ANSI)")
'Set parts list To a specific style'oPartsList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("MULTIPLE-SINGLE PARTS LIST")
oPartsList.Style = oPLS

'reposition parts list to top left
oPlaceX = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X)
oPlaceY = oBorder.RangeBox.MaxPoint.Y
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oPlaceX,oPlaceY)
oPartslist.position = oPlacementPoint
End Try

    auto = iLogicVb.Automation
    auto.RunExternalRule(oDrawDoc,"AutoFill Border")
'Return the Drawing Document 'Return oDrawDoc'Dim oBaseViewOptions As NameValueMap'oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap

' Set the representations to use when creating the base view.
 ' oBaseViewOptions.Add("PositionalRepresentation", "Position1")
  'oBaseViewOptions.Add("DesignViewRepresentation", "View1")
  'oBaseViewOptions.Add("DesignViewAssociative", True)'End Function

iProperties.Value("Project", "Project") = iProperties.Value(oPartDoc, "Project", "Project")



 

0 Likes
Accepted solutions (1)
1,506 Views
4 Replies
Replies (4)
Message 2 of 5

MechMachineMan
Advisor
Advisor

Hi,

 

You must use the .ScaleString method instead of the .Scale method to cause it to retain any formatting.

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-98EE9821-49B8-4293-B502-E3DD2E381D92

 

Good luck!


--------------------------------------
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
Message 3 of 5

Anonymous
Not applicable

MechMachine,

 

The scale is being generated from here:

 

Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 714 StartFragment: 314 EndFragment: 682 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

DrawingViewScale = 1/8

and if I change that to 1 the scale would be 1:1.  Right now I just right click on the view edit and change the scale to 1 1/2"=1'-0" drop down, but I want to automate this as per the drawing view creation.  Maybe its not possible?

 

Thanks for the reply!

0 Likes
Message 4 of 5

MechMachineMan
Advisor
Advisor
Accepted solution

It usually helps if you read and try to comprehend what people say.

 

See bolded and underlined ADDED LINE below.

 

Note, depending on what language you are using, each quotation marks needs to be replaced with either Chr(34) or CHAR(34), and the rest of the string needs to be put into proper string format.

 

'Function CreateDrawing_PlaceViews (PartNumber As String, DrawingViewScale As Double, ViewsToPlace As String, AssemblyDrawing As Boolean, ByRef oBaseView As DrawingView, ByRef oView2 As DrawingView, ByRef oView3 As DrawingView, ByRef oView4 As DrawingView)

Imports Inventor.ViewOrientationTypeEnum
Imports Inventor.DrawingViewStyleEnum

    Dim oDrawDoc As DrawingDocument
    Dim oPartDoc As Document
    Dim oSheet As Sheet
    'Dim oDrawDoc As DrawingDocument = ThisDoc.Document
    Dim oDrawingView As DrawingView
    'Dim oSheet As Sheet = oDrawDoc.ActiveSheet
    Dim oPlacementPoint As Point2d
    Dim oBorder As Border
    Dim oPlaceX As Double
    Dim oPlaceY As Double
    Dim oPartsList As PartsList 
    Dim AssemblyDrawing As Boolean
    
    'Dim oTG As TransientGeometry
    'Dim oPoint1 As Point2d
    'Dim oPoint2 As Point2d
    'Dim oPoint3 As Point2d

    
    Filename = ThisDoc.FileName(False)
    

    'If this is the Assembly View, then use this Document as reference and open Drawing Template
    'Otherwise use the given Part Number And invisibly open the part, Use the active drawing
    'f AssemblyDrawing = True Then
        'oPartDoc = ThisDoc.Document
    DocType = ThisDoc.Document.DocumentType
    If DocType = DocumentTypeEnum.kAssemblyDocumentObject Then
        oPartDocPath = ThisDoc.Path & "\" & Filename & ".iam"
        oPartDoc = ThisApplication.Documents.Open(oPartDocPath, False)
        oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "K:\Mech\INVENTOR2016\Inventor Resources\Templates\RAUTE_2016.dwg", True)
        oPLS = oDrawDoc.StylesManager.PartsListStyles.Item("MULTIPLE-SINGLE PARTS LIST")
    'Else AssemblyDrawing = False 
    Else If DocType = DocumentTypeEnum.kPartDocumentObject Then
        oPartDocPath = ThisDoc.Path & "\" & Filename & ".ipt"
        oPartDoc = ThisApplication.Documents.Open(oPartDocPath, False)
    'DrawDoc = ThisApplication.ActiveDocument 
        oDrawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, "K:\Mech\INVENTOR2016\Inventor Resources\Templates\RAUTE_2016.dwg", True)
        oPLS = oDrawDoc.StylesManager.PartsListStyles.Item("SINGLE PART LIST")
    End If
    
'Set a reference to the sheet format
Dim oFormat As SheetFormat
Try
oFormat = oDrawDoc.SheetFormats.Item("A-SIZE SHEET")
Catch
MessageBox.Show("Error: the named sheet format might not exist.", "iLogic")
Return
End Try
'Create a new sheet based on the sheet format using the specified model'Dim oSheet As Sheet
oSheet = oDrawDoc.Sheets.AddUsingSheetFormat(oFormat)    

oSheetName = "Sheet:1"
oSheet1 = ThisApplication.ActiveDocument.Sheets.Item(oSheetName) 
oSheet1.Delete

'oSheet = oDrawDoc.Sheets.Item(1)

oTG = ThisApplication.TransientGeometry
    'Dim oTG As TransientGeometry'Set points in order to get wanted View (ie. if 'Y' is the same and 'X' is greater or less, you will get a Side View)
    oPoint1 = oTG.CreatePoint2d(13, 12)

Dim DrawingViewScale As Double


'Dim ViewScale2 As Double

 '   ViewScale1 = 1.0
  '  ViewScale2 = 5.0

  
'RoundToFraction(DrawingViewScale, 1/32, RoundingMethod.Round)    
DrawingViewScale = 1/8


'Create the Base View
oBaseView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint1, DrawingViewScale, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle, "Master")
   
oBaseView.ScaleString = "1 1/2" & Chr(34) & "=1'-0" & Chr(34)
oBorder = oSheet.Border oDrawingView = oSheet.DrawingViews(1) oPlacementPoint = oBorder.RangeBox.MaxPoint 'oPlacementPoint = oBorder.RangeBox.MinPoint'oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(27,0) 'Create the parts list. Try oPartList = oSheet.PartsLists(1) Catch oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint) 'oDrawingView'Set parts list To a specific layer oPartsList.Layer = oDrawDoc.StylesManager.Layers.Item("Visible (ANSI)") 'Set parts list To a specific style'oPartsList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("MULTIPLE-SINGLE PARTS LIST") oPartsList.Style = oPLS 'reposition parts list to top left oPlaceX = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X) oPlaceY = oBorder.RangeBox.MaxPoint.Y oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oPlaceX,oPlaceY) oPartslist.position = oPlacementPoint End Try auto = iLogicVb.Automation auto.RunExternalRule(oDrawDoc,"AutoFill Border") 'Return the Drawing Document 'Return oDrawDoc'Dim oBaseViewOptions As NameValueMap'oBaseViewOptions = ThisApplication.TransientObjects.CreateNameValueMap ' Set the representations to use when creating the base view. ' oBaseViewOptions.Add("PositionalRepresentation", "Position1") 'oBaseViewOptions.Add("DesignViewRepresentation", "View1") 'oBaseViewOptions.Add("DesignViewAssociative", True)'End Function iProperties.Value("Project", "Project") = iProperties.Value(oPartDoc, "Project", "Project")

--------------------------------------
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 5 of 5

Anonymous
Not applicable

Thanks so much!! I'm really learning as I go!

0 Likes