AddBaseView giving Parameter incorrect error

AddBaseView giving Parameter incorrect error

tkennedy26
Enthusiast Enthusiast
1,104 Views
4 Replies
Message 1 of 5

AddBaseView giving Parameter incorrect error

tkennedy26
Enthusiast
Enthusiast

I'm trying to get started in the drawing environment with iLogic. But I can't even get the base view in. I'm referencing the API help "Adding Representation Views Api Sample". I won't have a LOD option but will need the view rep eventually which the API walks me through the .AddBaseView syntax. But I'm hoping someone can tell me why this is erroring out on the .AddBaseView Line.

Dim doc As DrawingDocument
doc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = doc.ActiveSheet
Dim modDoc As Document
modDoc = ThisApplication.Documents.Open("C:\test.iam", False)
oTG = ThisApplication.TransientGeometry
Dim oPoint As Point2d
oPoint = ThisApplication.oTG.CreatePoint2d(5, 5)
Dim oBVO As NameValueMap
oBVO = ThisApplication.TransientObjects.CreateNameValueMap
Dim oScale As Double
oScale = 0.125
Dim oViewName As String
oViewName = "test"


'MsgBox ("Made it thus far")
'Base View Options
    'Call oBVO.Add("PositionalRepresentation", oViewName)
    'Call oBVO.Add("DesignViewAssociative", True)
	
	oModelDoc = ThisDrawing.ModelDocument
	'Get full file path of model
	
Dim oBaseView As DrawingView
oBaseView = oSheet.DrawingViews.AddBaseView(oModelDoc,oPoint,oScale,kFrontViewOrientation,kHiddenLineRemovedDrawingViewStyle)

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

MechMachineMan
Advisor
Advisor
Accepted solution

Try simplifying the calls on the line until you isolate the issue. Or convert the code to VBA, and debug at the line.

 

Sometimes it's fussy and you need to declare all of the variables explicitly, other times, it could be that your enums aren't called off properly. (ie; Dim oModelDoc As Document // ViewOrientationTypeEnum.kFrontViewOrientation (or  the int 10764))

 

Or it could be something else all together.


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

bradeneuropeArthur
Mentor
Mentor

Hi,

 

This Code:

 

Public Sub CreateDrawingView()

        
Dim oInvApp As Application
Set oInvApp = ThisApplication

        Dim sTemplateFile As String

        Set sTemplateFile = "C:\Standard.dwg"

        Dim a As Document ' Document
        Set a = oInvApp.ActiveEditDocument

        oInvApp.SilentOperation = True

        Dim oDrawDoc As DrawingDocument
        Set oDrawDoc = oInvApp.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, sTemplateFile)

        oInvApp.SilentOperation = False

        ' The drawing is created with a single sheet,
        ' so we'll add our views to it.
        Dim oSheet As Sheet
        Set oSheet = oDrawDoc.Sheets.Item(1)

        ' Now we define the placement points for
        ' the two drawing views we shall be adding to the sheet
        Dim oPlacementPoint1 As Point2d

        'Set oPlacementPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(20#, 15#)
        Set oPlacementPoint1 = oInvApp.TransientGeometry.CreatePoint2d(oSheet.Width / 2, oSheet.Height / 2)

        ' Define the view scales that we need.
        Dim ViewScale1 As Double
        ViewScale1 = 1 / 5
        ' define the view orientation for each view

        Dim ViewOrientation1 As ViewOrientationTypeEnum
        Set ViewOrientation1 = ViewOrientationTypeEnum.kCurrentViewOrientation 

        ' define the view style for each view
        Dim ViewStyle1 As DrawingViewStyleEnum
        Set ViewStyle1 = DrawingViewStyleEnum.kHiddenLineDrawingViewStyle

        Dim sPartPath As String
        sPartPath = a.FullFileName

        Dim oPartDoc As Document
        'Set oPartDoc = ThisApplication.ActiveEditDocument
        Set oPartDoc = oInvApp.Documents.Open(sPartPath, False)

        ' now create our two views
        Dim oView As DrawingView
        Set oView = oSheet.DrawingViews.AddBaseView(oPartDoc, oPlacementPoint1, ViewScale1, ViewOrientation1, ViewStyle1)

        Dim NewScale As Double
        NewScale = 1

        'oView.Scale =
        oView.[Scale] = 1 / NewScale
        oDrawDoc.Save

        Dim strScale As String
        strScale = InputBox("Is the scale correct otherwise fill in", "Scale overwrite", NewScale)

        oView.[Scale] = 1 / strScale

        oDrawDoc.Update

    End Sub

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 4 of 5

tkennedy26
Enthusiast
Enthusiast

   Yep, but it in Visual Studio which I'm pretty novice at so I didn't think about it. and you were right, intellisense put in the "ViewOrientationTypeEnum.kFrontViewOrientation" after that it worked in iLogic.

Thanks for the help!

Working end line for reference:

Dim oBaseView As DrawingView = oSheet.DrawingViews.AddBaseView(modDoc, oPoint, oScale, ViewOrientationTypeEnum.kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle)

0 Likes
Message 5 of 5

tkennedy26
Enthusiast
Enthusiast

Thank you Bradeneurope, I just saw yours after I replied to MechMachineMan. I appreciate the help, I'll definitely use this as a reference as I keep going.

0 Likes