Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADD BASEVIEW ON SPECIFIC LAYER!

3 REPLIES 3
Reply
Message 1 of 4
ChristinaForest
436 Views, 3 Replies

ADD BASEVIEW ON SPECIFIC LAYER!

It's possible to add baseview on specific layer?

 

anybody have a code for that?

 

Thanks for you help 🙂

3 REPLIES 3
Message 2 of 4

Hi, 

You can't directly take drawing views to layer.But you can select all drawing curves & you can assign to any layer.I hope this link will guide you in right direction

http://forums.autodesk.com/t5/inventor-customization/ilogic-rule-to-change-drawing-view-layer/m-p/43...

 

Here i modified for base view :

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView
For Each oView In oSheet.DrawingViews
		' If it is a Baseview
    If oView.ViewType = KstandardDrawingViewType Then
	' Get Layers
     Dim oLayers As LayersEnumerator = oView.Parent.Parent.StylesManager.layers
	' Get CNC layer
	 Dim oLayer As Layer = oLayers.Item("0.1mm")
	' Get lines
	 Dim oCurves As DrawingCurvesEnumerator = oView.DrawingCurves()
	 Dim oCurve As DrawingCurve
	' For each line
		For Each oCurve In oCurves
		' Change the layer
			oCurve.Segments.Item(1).Layer = oLayer
		Next
    End If
Next

 

 

Message 3 of 4

Thanks for your help prokasht66 🙂

 

I know this code to change the layer view, what's i want it's to insert a baseview directly on a good layer!

 

Maybe someone have my solution 🙂

Message 4 of 4

As Prakasht66 mentioned, you can't do that. Take a look at the "DrawingViews.AddBaseView" method in the help and you will see that their is no option to set the layer before inserting the view.

 

You can however move all curves at once using the optimized API "Sheet.ChangeLayer":

 

' This sample demonstrates the performance difference of changing the layer
' of individual objects one at a time, or a group of objects at the same time.
' Make sure the g_FilePath variable points to where the Carb.ipt file is located.
' Other than that there are no requirements for running this sample since it
' creates its own drawing.
Public Sub DrawingChangeLayer()

    ' Create a new drawing
    Dim drawDoc As DrawingDocument
    Set drawDoc = ThisApplication.Documents.Add(kDrawingDocumentObject)
    
    Dim Tg As TransientGeometry
    Set Tg = ThisApplication.TransientGeometry
    
    ' Add drawing views of the same part and same orientation.
    Dim modelDoc As PartDocument
    Set modelDoc = ThisApplication.Documents.Open(g_FilePath & "Carb.ipt", False)
    
    Dim drawView1 As DrawingView
    Dim drawView2 As DrawingView
    Set drawView1 = drawDoc.activeSheet.DrawingViews.AddBaseView(modelDoc, Tg.CreatePoint2d(8, 8), 3, kFrontViewOrientation, kHiddenLineDrawingViewStyle)
    Set drawView2 = drawDoc.activeSheet.DrawingViews.AddBaseView(modelDoc, Tg.CreatePoint2d(20, 8), 3, kFrontViewOrientation, kHiddenLineDrawingViewStyle)

    ' Create a new layer to move the geometry to.
    Dim newLayer As Layer
    Set newLayer = drawDoc.StylesManager.Layers.item(1).Copy("My New Layer 1")
    newLayer.color = ThisApplication.TransientObjects.CreateColor(255, 0, 0)
    newLayer.LineType = kContinuousLineType

    Dim timer As New clsTimer
    
    ' Iterate over all of the curves in the first view and change their layer one at a time.
    timer.start
    Dim drawCurve As DrawingCurve
    For Each drawCurve In drawView1.DrawingCurves
        Dim curveSegment As DrawingCurveSegment
        For Each curveSegment In drawCurve.Segments
            curveSegment.Layer = newLayer
        Next
    Next
    
    Dim time1 As Double
    time1 = timer.CurrentTime
    
    Set newLayer = drawDoc.StylesManager.Layers.item(1).Copy("My New Layer 2")
    newLayer.color = ThisApplication.TransientObjects.CreateColor(0, 255, 0)
    newLayer.LineType = kContinuousLineType
        
    ' Change the layer for all curves at one time.
    timer.start
    Dim curves As ObjectCollection
    Set curves = ThisApplication.TransientObjects.CreateObjectCollection
    For Each drawCurve In drawView2.DrawingCurves
        For Each curveSegment In drawCurve.Segments
            Call curves.Add(curveSegment)
        Next
    Next
    
    Call drawDoc.activeSheet.ChangeLayer(curves, newLayer)
    
    Dim time2 As Double
    time2 = timer.CurrentTime
    
    Dim x As Double
    x = time1 / time2
    
    MsgBox "Change layer results for " & curves.count & " entities." & vbCr & "One at a time: " & VBA.Format(time1, "0.00000") & vbCr & "All at once: " & VBA.Format(time2, "0.00000") & vbCr & "Factor: " & VBA.Format(x, "0.00")

End Sub

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

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

Post to forums  

Autodesk Design & Make Report