Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extract value from leader text

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
287 Views, 5 Replies

Extract value from leader text

If I have a 2D drawing with an assembly and have 5 leaders (Leader Text). Would it be possible to extract that value from Leaders to an excel og xml file?

5 REPLIES 5
Message 2 of 6
Mark.Lancaster
in reply to: Anonymous

@Anonymous 

 

Via some coding I would assume so but nothing out of the box is going to do this for you..

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

Message 3 of 6
Sergio.D.Suárez
in reply to: Anonymous

Hi, Try this ilogic rule on the drawing sheet, take all the data from the leadernotes and place them on an excel sheet.

 

Dim oDoc As DrawingDocument = ThisDoc.Document
Dim OFullName As String = oDoc.FullFileName
'Remove file extension 
Dim oExcelName As String = Left(OFullName, (InStrRev(OFullName, ".", - 1, vbTextCompare) - 1)) & ".xlsx"

Dim row As Integer = 2  ''' Indicate from which row the read of excel values will begin
xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
xlWorkbook = xlApp.Workbooks.Add
xlWorksheet = xlWorkbook.Worksheets.Item(1)

For Each oLeaderNote As LeaderNote In oDoc.ActiveSheet.DrawingNotes.LeaderNotes
	oValue = oLeaderNote.Text
	xlWorksheet.Range("A" & row).Value = oValue
	row = row + 1 
Next    

'set all of the columns to autofit
xlWorksheet.Columns.AutoFit   
'save the file
xlWorkbook.SaveAs(oExcelName)
'xlWorkbook.Close
'xlApp.Quit
'xlApp = Nothing    

 I hope this helps. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 4 of 6
Anonymous
in reply to: Sergio.D.Suárez

That's really great!! Thank you!

 

Here comes next (tricky) part...

 

Now that I have my extracted value in column A, I would like to enter a Value in column B, that will replace the value in column A, once I import the values from my excel spreadsheet back into my drawing ...if it's possible to import that value back into the drawing?

 

Maybe the workflow could be that I

1. Insert leaders

2. Run the extract rule

3. Add values in column B, that will replace the values in column A

4. Save and close the spreadsheet

5. Run an import rule, that does the replacement of values in my leader texts

 

We would use it for TAG numbering on a layout, where we usually reserve the leader text with an $ and replace that text once we the TAG numbers from out PLC department

 

 

Message 5 of 6
Sergio.D.Suárez
in reply to: Anonymous

I do not fully understand the reason for using the excel table.
Could you try this simple code?

 

Dim oDoc As DrawingDocument = ThisDoc.Document

For Each oLeaderNote As LeaderNote In oDoc.ActiveSheet.DrawingNotes.LeaderNotes
	oValue = oLeaderNote.Text
	newValue = InputBox("Replace value: " & oValue, "Replace LeaderNote", oValue)
	If newValue <> oValue Then 	oLeaderNote.FormattedText = newValue
Next  

 This code changes each text of each leadernote. I think it would be more convenient than what you are looking for, in addition to not generating a new excel file. Excuse me if I do not understand the behavior of what you need, regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 6 of 6
Anonymous
in reply to: Sergio.D.Suárez

I've made the interface (see attached), maybe that gives and idea of what I'm making

 

What I want to do, is to run a sort of a batch job where the value in A2 gets replaced by the new value from B2

 

 

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

Post to forums  

Autodesk Design & Make Report