Add ''TYP. " to drawing dimension.

Add ''TYP. " to drawing dimension.

Sprocket1077
Enthusiast Enthusiast
805 Views
6 Replies
Message 1 of 7

Add ''TYP. " to drawing dimension.

Sprocket1077
Enthusiast
Enthusiast

Hi.

I found this vba macro on this forum and I would like to update it a bit.

Sub Main  AddSuffix()
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oDim As DrawingDimension
Dim oStr As String
For Each oDim In oDoc.SelectSet
oStr = oDim.Text.FormattedText + "<br/>TYP."
oDim.Text.FormattedText = oStr
Next
End Sub

 First I would like it to start from a button on the ribbon.

Then I want it to ask : How many "TYP." do you need? so the macro should record "TYP. 2" if I answered "2" to the question.

And then, pick all dimensions you need to apply the text.

It should end with a "OK - Cancel" button.

 

I know it looks like a bit weird, but I'll save a lot of clicks with this.

 

Thanks for any help.

 

0 Likes
Accepted solutions (2)
806 Views
6 Replies
Replies (6)
Message 2 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @Sprocket1077 

 

Here's a version of this that I think will fit your requirements. Post back if not.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

oInput = InputBox("Enter number for TYP.#", "iLogic", "2")
If oInput = "" Then Return
	
While True
	
	'select the line segments	
	Dim oDim As GeneralDimension 
	oDim = ThisApplication.CommandManager.Pick _
		(SelectionFilterEnum.kDrawingDimensionFilter, _
		"Select dimesions to make to add TYP. " & oInput & " (press ESC To Exit selection)")
	
	If IsNothing(oDim) Then Exit While
		
	'set the segment color
	oDim.Text.FormattedText = "<br/>TYP." & oInput

End While

 

 

EESignature

0 Likes
Message 3 of 7

Sprocket1077
Enthusiast
Enthusiast

Thank you Curtis_W.

It works just fine.

0 Likes
Message 4 of 7

Sprocket1077
Enthusiast
Enthusiast

Curtis_W

It works fine, but I would like to know if we could do some little modifications.

Could it be possible for the question :

		"Select dimesions to make to add TYP. " & oInput & " (press ESC To Exit selection)"

 to appear only on the command line (bottom of screen) and not beside the cursor? (like a standard Inventor command)

Second question, instead of " (press ESC To Exit selection)", could it be possible to right click and select OK or CANCEL?

My last interrogation is, I have difficulty to transform this iLogic expression into a vba macro that will be apply to a button.  Do you have tips for this application?

 

Again I know that this is very particular , but at the end it will be a very nice macro.

Thank you and sorry for the complications (and my english).

0 Likes
Message 5 of 7

Curtis_Waguespack
Consultant
Consultant

Hi @Sprocket1077 

 

Unfortunately, the Pick command is pretty limited. You can set that string to just read "Select Dimensions" if you'd prefer, but it still requires an Escape to move past the selection mode.... which of course is not the most intuitive thing, so that is why I typically add that to the prompt string. 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
 

EESignature

0 Likes
Message 6 of 7

Curtis_Waguespack
Consultant
Consultant
Accepted solution

 

 

To add iLogic rules as a button, this addin created by @JelteDeJong is probably the best option.

 

https://apps.autodesk.com/INVNTOR/en/Detail/Index?id=2268703737300536294

 

 

As for converting this to run with VBA, it could be done, but without digging into I don't know what all it would take.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

EESignature

0 Likes
Message 7 of 7

Sprocket1077
Enthusiast
Enthusiast

Hi Curtis_W.

Thank you very much for your help.

0 Likes