Checked Camera view button in vb.net

Checked Camera view button in vb.net

m_reza_shahparast
Contributor Contributor
288 Views
8 Replies
Message 1 of 9

Checked Camera view button in vb.net

m_reza_shahparast
Contributor
Contributor

1000127671.jpg

 hi dears

Please help me

How i can checked this (Camera view) after i added the base view in vb.net? 

 

0 Likes
289 Views
8 Replies
Replies (8)
Message 2 of 9

WCrihfield
Mentor
Mentor

Hi @m_reza_shahparast.  My guess is that view you are editing is a 'projected' view, instead of a 'base' view or 'ISO' view.  I don't think it will let you change that property for projected views, but it should let you do that for base views or ISO views.  I think this is because the angle of the camera in  projected view is dictated by the base view that the are projected from.

But no, I could not find a property of the view for that setting either.  I do know about the other one shown there though:  DrawingView.Include3DAnnotations 

Edit:  Wait, I remember now.  There is a rather indirect way to set that setting.  You have to go through the DrawingView.Camera property, then set the Camera.ViewOrientationType property's value to the "kSavedCameraViewOrientation" variation of the ViewOrientationTypeEnum.  That forces it to use the camera saved within the design view in the model.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 9

m_reza_shahparast
Contributor
Contributor

Thanx so much

If let me, tomorrow i send my code here and you tell me whats my problem in code..

I using (saved view) but dont work

 

0 Likes
Message 4 of 9

m_reza_shahparast
Contributor
Contributor

Sub drawingView(oPart As PartDocument, oPath As String)

 

    Dim ThisApplication As Inventor.Application = GetObject(, "Inventor.Application")

    Dim oDwgs As Inventor.DrawingDocument

 

    Try

        oDwgs = ThisApplication.Documents.Open(oPath, True)

    Catch ex As Exception

        

        Return

    End Try

 

    oDwgs.ReleaseReference()

    oDwgs.Save()

 

    Dim oDwgSh = oDwgs.ActiveSheet

    Dim oSc = oOD / 140

    Dim oL = oDwgSh.Width

    Dim oW = oDwgSh.Height

 

    Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

 

    'Centerlines

    Dim oACS As AutomatedCenterlineSettings = oDwgs.DrawingSettings.AutomatedCenterlineSettings

 

    oACS.ApplyToBends = False

    oACS.ApplyToCircularPatterns = True

    oACS.ApplyToCylinders = True

    oACS.ApplyToRevolutions = True

    oACS.ApplyToHoles = True

    oACS.ApplyToFillets = False

    oACS.ApplyToPunches = False

    oACS.ApplyToRectangularPatterns = False

    oACS.ApplyToSketches = False

    oACS.ApplyToWorkFeatures = False

    oACS.ProjectionNormalAxis = True

    oACS.ProjectionParallelAxis = True

 

    Dim oSheet As Sheet = oDwgs.ActiveSheet

    For Each oCM As Centermark In oSheet.Centermarks

        oCM.Delete()

    Next

    For Each oCL As Centerline In oSheet.Centerlines

        oCL.Delete()

    Next

 

    'BaseViews

    Dim oDwgVBase = oDwgSh.DrawingViews.AddBaseView(oPart, oTG.CreatePoint2d(0, 0), 1 / oSc, ViewOrientationTypeEnum.kRightViewOrientation, ViewStyle:=DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle)

    oDwgVBase.Include3DAnnotations = True

 

    Dim oVL = oDwgVBase.Width

    Dim oVW = oDwgVBase.Height

 

    Dim Y = oW - (oVW / 2) - 6

    Dim X = (oVL / 2) + 4

 

    oDwgVBase.Position = oTG.CreatePoint2d(X, Y)

    oDwgVBase.SetAutomatedCenterlineSettings(oACS)

 

    'Right View

    'Dim oDwgV = oDwgSh.DrawingViews.AddProjectedView(oDwgVBase, oTG.CreatePoint2d(oDwgVBase.Position.X + 12, Y), ViewStyle:=DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)

    'oDwgV.Include3DAnnotations = True

    Dim oDwgV = oDwgSh.DrawingViews.AddBaseView(oPart, oTG.CreatePoint2d(oDwgVBase.Position.X + 12, Y), 1 / oSc, ViewOrientationTypeEnum.kSavedCameraViewOrientation, ViewStyle:=DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)

    oDwgV.Include3DAnnotations = True

    oDwgV.Camera.ViewOrientationType = ViewOrientationTypeEnum.kSavedCameraViewOrientation

    Dim oSketch = oDwgV.Sketches.Add()

    Dim oRectX As Double = 50

    Dim oRectY As Double = 50

    Dim bottomRight As Object = oTG.CreatePoint2d((oOD / 20) + oRectX, oTHK + oRectY)

    Dim oCenView As Object = oTG.CreatePoint2d(0, 0)

    oSketch.Edit()

    Dim oRECT = oSketch.SketchLines.AddAsTwoPointCenteredRectangle(oCenView, bottomRight)

    oSketch.ExitEdit()

    Dim prof As Profile = oSketch.Profiles.AddForSolid()

    Dim oAxis As GeometryIntent = oDwgV.Position

    oDwgV.BreakOutOperations.Add(prof, oDwgV.DrawingCurves(oPart.ComponentDefinition.Features.ExtrudeFeatures.Item("Bolt")), 0)

 

    '3D View

    Dim o3DView = oDwgSh.DrawingViews.AddBaseView(oPart, oTG.CreatePoint2d(oDwgSh.Width - 7, Y), 0.8 / oSc, ViewOrientationTypeEnum.kIsoTopRightViewOrientation, ViewStyle:=DrawingViewStyleEnum.kShadedDrawingViewStyle)

    o3DView.Label.FormattedText = "3D View"

    o3DView.Label.TextStyle.FontSize = 0.4

 

    'PartList

    Dim oBorder = oSheet.Border

    Dim oPartsList = oDwgSh.PartsLists.Add(oDwgVBase, oBorder.RangeBox.MinPoint)

    Dim oPlaceX = oBorder.RangeBox.MinPoint.X + (oPartsList.RangeBox.MaxPoint.X - oPartsList.RangeBox.MinPoint.X)

    Dim oPlaceY = oBorder.RangeBox.MinPoint.Y + (oPartsList.RangeBox.MaxPoint.Y - oPartsList.RangeBox.MinPoint.Y)

    Dim oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(oPlaceX, oPlaceY)

    oPartsList.Position = oPlacementPoint

 

    'Blocks

    Dim oBlock1 As AutoCADBlockDefinition = oDwgs.AutoCADBlockDefinitions.Item(1)

    Dim oBlock2 As AutoCADBlockDefinition = oDwgs.AutoCADBlockDefinitions.Item(2)

    Dim oBlock3 As AutoCADBlockDefinition = oDwgs.AutoCADBlockDefinitions.Item(3)

    If oType <> "VII" Then

        If oJackTrue = True Then

            Dim oB1 = oDwgSh.AutoCADBlocks.Add(oBlock1, oTG.CreatePoint2d(2, oPlaceY + 0.4), 0, 1.3)

            oB1.Static = True

        End If

        If oDowelTrue = True Then

            Dim oB2 = oDwgSh.AutoCADBlocks.Add(oBlock2, oTG.CreatePoint2d(7, oPlaceY + 0.4), 0, 1.3)

            oB2.Static = True

        End If

        If oType = "II" Or oType = "IV" Or oType = "VI" Then

            Dim oB3 = oDwgSh.AutoCADBlocks.Add(oBlock3, oTG.CreatePoint2d(12, oPlaceY + 0.4), 0, 1.3)

            oB3.Static = True

        End If

    End If

 

    'TitleBlock

    Dim oTitleDef As TitleBlockDefinition = oDwgs.TitleBlockDefinitions.Item(1)

    oDwgs.ActiveSheet.TitleBlock.Delete()

    Dim oTitle = oDwgSh.AddTitleBlock(oTitleDef, TitleBlockLocationEnum.kBottomRightPosition)

 

    oDwgs.Save2()

    oDwgs.Update()

    oDwgs.Update2()

    oDwgs.Save2()

 

End Sub

 

0 Likes
Message 5 of 9

WCrihfield
Mentor
Mentor

Hi @m_reza_shahparast.  That's a lot of code to look over. Are you intending to use this within iLogic rules, or somewhere else?  In iLogic rules we must always have a 'Sub Main...our code...End Sub' block of code, then other custom routine blocks of code can be after that.  There are a some things in the code that I do not understand, such as the following line of code:

Dim oSc = oOD / 140

...just as one example.  What does the variable named 'oOD' represent, where was it declared, and where did it get a value set to it before that point in the code.  I see that 'oSc' variable being used in several places later in your code, but wander if it ever got a proper value assigned to it.

After you do something with a Camera, you should always follow that with something like Camera.Apply or Camera.ApplyWithoutTransition, which are methods for applying any changes made to it, so they will take effect.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 9

m_reza_shahparast
Contributor
Contributor

Dear Sir,

You are right. That was my mistake. It is the VB.NET code.

Regarding the argument that you mentioned, which is the same as `oOD`, I defined these arguments using `Public Shared oOD As Double` at the top of the class.

Thank you for your help. However, that problem is now solved, and I have another issue.

If you allow me, I will send it to you tomorrow.

The new problem is related to finding the intersection point of two geometry elements for adding a dimension in VB.NET code.

Best regards,

0 Likes
Message 7 of 9

m_reza_shahparast
Contributor
Contributor

Considering i have 4 argument as object then for these arguments getting drawing curve and now i want to getting intersection poit of 1 and 2 , and add dimension  dimension between intersection point and 3 

0 Likes
Message 8 of 9

WCrihfield
Mentor
Mentor

Hi @m_reza_shahparast.  I am honestly not super experienced at creating dimensions within drawings entirely by code, because although we do use do use some automation in our designs where I work, we do not automate the process of adding the dimensions (or other types of annotations) to our drawings.  So, I may not be the best person to help with that specific task.  I am familiar with the Inventor API Sheet.CreateGeometryIntent method, but I do not recall ever using it to define an 'intersection' for attaching a dimension (or other annotation) to before.  It sound like you would supply one piece of the intersecting geometry as the first 'input parameter' it is asking for named "Geometry", then I assume you would have to supply the other piece of intersecting geometry as the second input parameter it is asking for named "Intent".  But that is just a guess on my part.

However, if you are using uniquely iLogic tools for your dimensioning, then you may be using one of the methods defined under the IManagedDrawingView Interface for getting a GeometryIntent.  Those method work a bit differently, and generally ask you for the names of the objects involved, instead of the actual objects themselves, and may ask for different types of inputs.  I don't really use any of those either, simply because I don't have any need to where I work.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 9 of 9

m_reza_shahparast
Contributor
Contributor

Thanks so much dear @WCrihfield for your time  🪴🌹🪴🫡

0 Likes