Insert Drawing Note at Mouse Click (x,y) Location - Total WT of Ref Component in Drawing View
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I am creating a macro, ultimately a button down the line, that allows me to: 1. click on a drawing view, 2. retrieve the reference component weight, 3. insert a text note listing the weight at a specified location. I currently have code that does 1 & 2 and part of 3. I am getting hung up on placing the fitted note at a specified location. Ultimately I want the UI to go like this: Prompt me to select a weight, Prompt me to select a location for the note, note appears. Below is the code I currently have. FYI I have a couple message boxes in play now just to make sure I am receiving the right values.
**Additionally, bonus points for telling me how to round my lb mass to the nearest 1lb. **
Public Sub TotalWT()
Debug.Print ThisApplication.Caption
'define active document as drawing doc. Will produce an error if its not a drawing doc
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
'Set sheet to be active sheet in window
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
'Get the desired view via user mouse click
Dim oDrawingView As DrawingView
Set oDrawingView = ThisApplication.CommandManager.Pick(kDrawingViewFilter, "Select the drawing view")
'Retrieve the mass of the drawing views referenced part
oMassKG =oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument.ComponentDefinition.MassProperties.Mass
'convert to lb mass
oMassLbs = oMassKG * 2.20462
MsgBox (" The Mass of the Item is " & oMassLbs & "lbmass")
'Define something to store x y point
Dim oTG As TransientGeometry
***Iknow somewhere in here is where I need to assign my mouse click points to my transient geo but can figure out how to capture mouse click x,y***
'Create the general note
Dim oGeneralNote As GeneralNote
'this is where I need to add my points as x, y
Set oGeneralNote = oSheet.DrawingNotes.GeneralNotes.AddFitted((0 14),"Total WT:" & oMassLbs)
End Sub