creating sketch symbol position based on work points!

creating sketch symbol position based on work points!

vinayababu.yerneni
Enthusiast Enthusiast
376 Views
2 Replies
Message 1 of 3

creating sketch symbol position based on work points!

vinayababu.yerneni
Enthusiast
Enthusiast

Hi, I'm trying to add a center line in my drawing, i'm using a work point to insert the sketch symbol (center Line) and same work point for addressing the dimensions too.

 

My question here is can i insert the sketch symbol (Center line) based on a work point position? If Yes, How can I?

 

How can I give the work point or work point Proxy as a reference co-ordinates for my sketch symbol Insertion point?.

 

Code Below:

 

sub DIMENSIONS()

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
Set oSheet = oDoc.ActiveSheet

Dim oView As DrawingView
Set oView = oSheet.DrawingViews(1)

Dim oAssDoc As AssemblyDocument
Set oAssDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument

Dim oAssCompDef As AssemblyComponentDefinition
Set oAssCompDef = oAssDoc.ComponentDefinition

Dim oOcc As ComponentOccurrence

Dim oOccs As ComponentOccurrences
Set oOccs = oAssDoc.ComponentDefinition.Occurrences
Dim oName(10) As String
oCount = 0


For Each oOcc In oOccs

If oCount = 2 Then

Exit For

Else

i = 0
Dim oDC As Document
Set oDC = oOcc.Definition.Document
Debug.Print oDC.ComponentDefinition.WorkPoints.count

For Each wp In oDC.ComponentDefinition.WorkPoints

If wp.Name = "LVCL" Or wp.Name = "HVCL" Or wp.Name = "CCL" Or wp.Name = "CCR" Then

Debug.Print wp.Name
oName(i) = wp.Name
i = i + 1


End If

Next
Call ProxyCL(oName(0), oName(1), oOcc, oSheet, oView)

oCount = oCount + 1
End If
Next
End Sub

 

--------------------------------------------------

Public Function ProxyCL(oName1 As String, oName2 As String, oOcc1 As ComponentOccurrence, oSheet As Sheet, oView As DrawingView)

Dim oDocDef As Document
Set oDocDef = oOcc1.Definition.Document


'Dim oAssDoc As AssemblyDocument
'Set oAssDoc = Oview.ReferencedDocumentDescriptor.ReferencedDocument


Set WP1 = oDocDef.ComponentDefinition.WorkPoints.Item(oName1)
Set WP2 = oDocDef.ComponentDefinition.WorkPoints.Item(oName2)

Dim wpProxy1 As WorkPointProxy
Dim wpProxy2 As WorkPointProxy
Call oOcc1.CreateGeometryProxy(WP1, wpProxy1)
Call oOcc1.CreateGeometryProxy(WP2, wpProxy2)

Dim oCM1 As Centermark
Set oCM1 = oSheet.Centermarks.AddByWorkFeature(wpProxy1, oView)
Dim oCM2 As Centermark
Set oCM2 = oSheet.Centermarks.AddByWorkFeature(wpProxy2, oView)

oCM1.Visible = False
oCM2.Visible = False

Dim oLeaderPoint As ObjectCollection
Set oLeaderPoint = ThisApplication.TransientObjects.CreateObjectCollection
Call oLeaderPoint.Add(oCM1)
Call oLeaderPoint.Add(oCM2)

Dim oPosition As Point2d
set oPosition = oSheet.

Dim CL As Centerline
Set CL = oSheet.CENTERLINES.Add(oLeaderPoint)

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

Dim SK As SketchedSymbolDefinition
Set SK = oDoc.SketchedSymbolDefinitions.Item("TANK CL")

Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry

Dim oSketchedSymbol As SketchedSymbol
Set oSketchedSymbol = oSheet.SketchedSymbols.Add(SK, oPosition, , 1)

End Function

 

0 Likes
Accepted solutions (1)
377 Views
2 Replies
Replies (2)
Message 2 of 3

dalton98
Collaborator
Collaborator
Accepted solution

I'm not exactly sure what you mean by centerline from a workpoint. Do you want the workpoint to be part of the centerline? If so you could just make it a centermark then extend its sides like this:

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet = oDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
Dim oPartDoc As PartDocument = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oWP as WorkPoint
oWP = oPartDoc.ComponentDefinition.WorkPoints.Item(2)
Dim oCm As Centermark oCm = oSheet.Centermarks.AddByWorkFeature(oWP, oView) Dim oPoint1 As Point2d Dim oPoint2 As Point2d oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(0, oCm.Position.Y + 5) oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(0, oCm.Position.Y - 5) oCm.ExtensionPointTwo = oPoint1 oCM.ExtensionPointFour = oPoint2

 

0 Likes
Message 3 of 3

vinayababu.yerneni
Enthusiast
Enthusiast

@dalton98 Thank you so much, the oCm1 position is what I exactly what im looking for and wanted and to access its position for my dimensions and center marks, you made the problem look easier for me now.

0 Likes