Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

DrawingView.SetIncludeStatus where is my centerline/centermark?

Josh_Hunt
Advocate

DrawingView.SetIncludeStatus where is my centerline/centermark?

Josh_Hunt
Advocate
Advocate

 

My function creates the centerline or centermark as expected. SetIncludeStatus does not return an object and I need to resize and dimension to the centerline or centermark.

 

    Function CreateCLine(Sht As Sheet, dv As DrawingView, occ As Object, AxisName As String) As Centerline
        Dim docDesc As DocumentDescriptor = dv.ReferencedDocumentDescriptor
        Dim Doctype As DocumentTypeEnum = docDesc.ReferencedDocumentType
        
        'get objects
        If Doctype = DocumentTypeEnum.kPartDocumentObject
            includeObj = occ.Definition.WorkAxes(AxisName)
        Else    ''assembly, so GET PROXY OF OCCURRENCE
            includeObj = ASI_.getWorkAxisProxy(occ, AxisName)
        End If
        
        'includes objects
        dv.SetIncludeStatus(includeObj, True)
        
        ''find centerline that was just created
        Dim newCL As Centerline
        For Each CL As Centerline In Sht.Centerlines
            If CL.ModelWorkFeature Is includeObj
                newCL = CL
                Exit For
            End If
        Next
        Return newCL
    End Function

 

The end of my function tries to find what was just created by looking at the ModelWorkFeature. But I have 2 problems...

  • I don't know if it created a centerline or centermark.
  • I will have projected views that create a centerline or centermark using the same Axis.

Any ideas, about how to find what I just created?

Josh Hunt
0 Likes
Reply
Accepted solutions (1)
1,384 Views
7 Replies
Replies (7)

chandra.shekar.g
Autodesk Support
Autodesk Support

@Josh_Hunt,

 

Provided iLogic code works fine. If axis is projected as centerline. 

 

Say for a example, A part which contains 3 default workAxes namely X Axis, Y Axis and Z Axis. Out of 3 axis, only 2 axis will create centerline and another axis will create centermark. This is because, Drawing document is mapped in 2D coordinate system.

 

In this example, if X axis and Y axis in front view will create centerlines. Then, Z axis will create centermark due to reason that unable to project. This is default behavior of drawing document.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes

Josh_Hunt
Advocate
Advocate

Hello @chandra.shekar.g

I understand how Inventor includes axis to create centermarks and centerlines. I think I need to clarify the problem.

 

The code is a very small part of a larger project. I will be creating several BASE views and PROJECTED views of different parts and assemblies on the same sheet. My function only works for 1 view but I need to INCLUDE the X Axis (and several other objects) in the base view and a projected view.

 

After it is INCLUDED, how do I know if it created a centerline or centermark?

Josh Hunt
0 Likes

bradeneuropeArthur
Mentor
Mentor
You don't know that.
You only can see that on the orientation of the model in the view.

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@Josh_Hunt,

 

Just track the count of Centermarks and Centerlines in same sheet before and after including workaxis. If any one is incremented, then consider that as created one by workaxis.

 

Ex: If centermark is increamented by one means centermark is created by including WorkAxis from the model.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



bradeneuropeArthur
Mentor
Mentor
Can you let that see by coding?

Regards,

Arthur Knoors

Autodesk Affiliations:

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: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 !

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support

@bradeneuropeArthur

 

Sure, below is the code for the same.

 

Function CreateCLine(Sht As Sheet, dv As DrawingView, occ As Object, AxisName As String) As Centerline
        Dim docDesc As DocumentDescriptor = dv.ReferencedDocumentDescriptor
        Dim Doctype As DocumentTypeEnum = docDesc.ReferencedDocumentType
        
        'get objects
        If Doctype = DocumentTypeEnum.kPartDocumentObject
            includeObj = occ.Definition.WorkAxes(AxisName)
        Else    ''assembly, so GET PROXY OF OCCURRENCE
            includeObj = ASI_.getWorkAxisProxy(occ, AxisName)
        End If
	DIm oCMStatus as Boolean
	oCMStatus = false 
	Dim oCLStatus as Boolean 
	oCLStatus = false
	
	DIm cmCnt as integer 
	cmCnt = Sht.CenterMarks.Count
	Dim clCnt as integer 
	clCnt = Sht.Centerlines.Count
        
        'includes objects
        dv.SetIncludeStatus(includeObj, True)
	
	If Sht.Centermarks.Count > cmCnt Then
		oCMStatus = True		
	Else If Sht.Centerlines.Count > clCnt Then
		oCLStatus = True
	End If
        
        ''find centerline that was just created
        Dim newCL As Centerline
        For Each CL As Centerline In Sht.Centerlines
            If CL.ModelWorkFeature Is includeObj
                newCL = CL
                Exit For
            End If
        Next
        Return newCL
    End Function

Thanks and regards, 

 


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Josh_Hunt
Advocate
Advocate
Accepted solution

@chandra.shekar.g you were thinking the same as I was. I updated my function yesterday morning. This makes sure you get the correct object by combining all centermarks and centerlines. Then I maintain a list of all known center objects in a shared variable "shtCenterObjsKnown". Then I find my object by process of elimination.

 

In my drawings, I shouldn't have more than 50 center objects so this is manageable.

 

@chandra.shekar.g would the Ideastation be the best place to request an enhancement to the API?

 

 

 

 

    Function CreateCenterObj(Sht As Sheet, dv As DrawingView, occ As Object, FeatureName As String) As Object
        Dim docDesc As DocumentDescriptor = dv.ReferencedDocumentDescriptor
        Dim Doctype As DocumentTypeEnum = docDesc.ReferencedDocumentType
        
        ''get object
        Select True
            Case FeatureName.Contains("Plane")
                If Doctype = DocumentTypeEnum.kPartDocumentObject
                    includeObj = occ.Definition.WorkPlanes(FeatureName)
                Else    ''assembly, so GET PROXY OF OCCURRENCE
                    includeObj = ASI_.getWorkPlaneProxy(occ, FeatureName)
                End If
            Case FeatureName.Contains("Axis")
                If Doctype = DocumentTypeEnum.kPartDocumentObject
                    includeObj = occ.Definition.WorkAxes(FeatureName)
                Else    ''assembly, so GET PROXY OF OCCURRENCE
                    includeObj = ASI_.getWorkAxisProxy(occ, FeatureName)
                End If
            Case FeatureName.Contains("Point")
                If Doctype = DocumentTypeEnum.kPartDocumentObject
                    includeObj = occ.Definition.WorkPoints(FeatureName)
                Else    ''assembly, so GET PROXY OF OCCURRENCE
                    includeObj = ASI_.getWorkPointProxy(occ, FeatureName)
                End If
        End Select
        
        dv.SetIncludeStatus(includeObj, True)
        '''GREAT, I made a centermark or centerline but now I have to find it...ahhhhh
        
        ''Build collection of ALL centermarks and centerlines on sheet
        Dim shtCenters As ObjectCollection = ThisServer.TransientObjects.CreateObjectCollection
        shtCenters.clear    'reset just to be sure
        For Each CL As Centerline In Sht.Centerlines
            shtCenters.Add(CL)
        Next
        For Each CM As Centermark In Sht.Centermarks
            shtCenters.Add(CM)
        Next
        
        ''remove known center objects from list of ALL centermarks and centerlines on sheet
        For Each cObjKnown In shtCenterObjsKnown
            shtCenters.RemoveByObject(cObjKnown)
        Next
        ''shtCenters.count should be 1
        
        If shtCenters(1).ModelWorkFeature Is includeObj And shtCenters.count = 1
            shtCenterObjsKnown.Add(shtCenters(1))    ''add to list of known
            newCntr = shtCenters(1)    'define as new object found
        End If
        
        Return newCntr
    End Function

 

Josh Hunt
0 Likes