Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to remove dash with ilogic

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
GosponZ
989 Views, 6 Replies

how to remove dash with ilogic

If you guys can help please, I need my part number to be same as program number.Part is 123-123 but program number need to be without "-". It should look like this 123123. So no dashes no space just whole number.

What i did it working but make dash too. Is it possible upgrade my rule to do what i described above?

Thanks a lot for any input.

'prompt user for iProperty value

booleanParam = InputRadioBox("Program Number?", "Yes", "No", booleanParam, Title := "Select option")

 

'set iproperties based upon user input

If booleanParam = True Then

iProperties.Value("Custom", "Program") = iProperties.Value("Project", "Part Number")

Else

booleanParam = False

iProperties.Value("Custom", "Program") = ""

End If

6 REPLIES 6
Message 2 of 7
jdkriek
in reply to: GosponZ

Remember iLogic is essentially VB.net, so you can use the Replace() function

 

Example:

 

String.Replace("CharacterToReplace", "")

 

Here's the revised code for you:

 

If booleanParam = True Then
	Dim PartNumber As String = iProperties.Value("Project", "Part Number")
	iProperties.Value("Custom", "Program") = PartNumber.Replace("-", "")
Else
	booleanParam = False
	iProperties.Value("Custom", "Program") = ""
End If
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 3 of 7
GosponZ
in reply to: jdkriek

Jonathan,

Thanks a lot .it is working perfect Smiley Happy

Message 4 of 7
jdkriek
in reply to: GosponZ

Quite welcome 😉

Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


Message 5 of 7
LOONYLEN
in reply to: jdkriek

Jonathan,

 

Is there a way to modify this code to remove a dash and three digits (whatever the digits may be "-XXX") from a part number and place it in the title block? Example: 485762-002 to 485762.

Senior Designer/Cad Administrator
Inventor 2012, w/SP2
Vault Collaboration 2012
Dell Precision T3500, Intel Xeon CPU
W3680 @3.33GHz, 16.0 GB of RAM
Microsoft Windows 7 Pro, 64 Bit Edition
Version 2009, w/SP1
Message 6 of 7
falkmassmann
in reply to: LOONYLEN

You could use substring for string manipulation.

If you´re 100% sure it´s always the last three digits of the part number you could do the following.

 

Dim partnumber As String = partnumber.substring(0,partnumber.length-3)

 

or if you want to remove the dash as well just -4.

 

regards

 

Falk

Message 7 of 7
jdkriek
in reply to: LOONYLEN


@LOONYLEN wrote:

Jonathan,

 

Is there a way to modify this code to remove a dash and three digits (whatever the digits may be "-XXX") from a part number and place it in the title block? Example: 485762-002 to 485762.


Several ways to do this:

 

'using Substring
Dim sPartNumber As String = "485762-002"
sPartNumber = sPartNumber.Substring(0, sPartNumber.IndexOf("-"))
MsgBox(sPartNumber & " using Substring()")

'using Split()
Dim sPartNumber2 As String = "485762-002"
sPartNumber2 = sPartNumber2.Split("-"c)(0)
MsgBox(sPartNumber2 & " using Split()")

 

Could also use Left() with InStr() - but you get the idea.

 


@falkmassmann wrote:

You could use substring for string manipulation.

If you´re 100% sure it´s always the last three digits of the part number you could do the following.

 

Dim partnumber As String = partnumber.substring(0,partnumber.length-3)

 

or if you want to remove the dash as well just -4.

 

regards

 

Falk


You don't need to be sure of the number of digits if you use IndexOf - just that it has a dash.

 

sPartNumber.Substring(0, sPartNumber.IndexOf("-"))
Jonathan D. Kriek
MFG Solutions Engineer
KETIV Technologies, Inc.


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

Post to forums  

Autodesk Design & Make Report