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: 

Identify beam and continue rule otherwise exit

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Benjaaamin
235 Views, 3 Replies

Identify beam and continue rule otherwise exit

Hi folks,

 

I have the below snippet 'Select Beam' which pulls through the parameters of a frame gen beam and holds them locally in the assembly level parameters.

Select Beam.jpg

 

Dim doc = ThisApplication.ActiveDocument
Dim BeamPick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter,"Select Beam") 
			
	If (Not BeamPick Is Nothing) Then
    	oBeamName = BeamPick.Name
	End If

'Beam parameters are extracted to local assembly parameters
If (Not BeamPick Is Nothing) Then
	Beam = BeamPick.Name
		SPL_W1 = Floor(Parameter(Beam, "G_W")/2 - (Parameter(Beam, "G_T")/2))-SetBack
		SPL_L1 = Floor(Parameter(Beam, "G_H") -(2 * (Parameter(Beam, "G_T1")))) -HSetBack
		DPL_H = Parameter(Beam, "G_H")
		Web = Parameter(Beam, "G_T")
		Flange = Parameter(Beam, "G_T1") 
		Rad = Ceil(Round((Parameter(Beam, "G_IR") + 2)) / 5) * 5
End If
		
RuleParametersOutput()
InventorVb.DocumentUpdate()
ThisApplication.ActiveView.Fit

If the incorrect component is selected I get the following error -

Select Beam Error.jpg

 

What I'm looking to achieve is a means of rather than getting an error is to exit the rule. 

Can anyone suggest something I can add to my snippet that can do this? Would this pull some kind of detail from the iproperties?

 

I also have a similar rule called 'Select SHS' that I would like to achieve the same thing with.

 

Any help is appreciated!

 

Labels (2)
3 REPLIES 3
Message 2 of 4
Michael.Navara
in reply to: Benjaaamin

You can use Try-Catch block. this is the easiest way. Or you need to check the picked component if it contains all required parameters.

Message 3 of 4
nstevelmans
in reply to: Benjaaamin

Hi, Maybe this can help

 

 

Dim doc = ThisApplication.ActiveDocument

Dim oCC As ComponentDefinition
Dim oPartdoc As PartDocument

Dim BeamPick As ComponentOccurrence
 BeamPick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select Beam") 


Try
	
	'Beam parameters are extracted to local assembly parameters
If (Not BeamPick Is Nothing) Then
	Beam = BeamPick.Name
		SPL_W1 = Floor(Parameter(Beam, "G_W")/2 - (Parameter(Beam, "G_T")/2))-SetBack
		SPL_L1 = Floor(Parameter(Beam, "G_H") -(2 * (Parameter(Beam, "G_T1")))) -HSetBack
		DPL_H = Parameter(Beam, "G_H")
		Web = Parameter(Beam, "G_T")
		Flange = Parameter(Beam, "G_T1") 
		Rad = Ceil(Round((Parameter(Beam, "G_IR") + 2)) / 5) * 5
End If

	 Catch 
	MsgBox("Missing Parameters in " & BeamPick.Name & ".ipt" &" Open the Part en check if G_IR,G_T1,G_H,G_W exist",MsgBoxStyle.Critical, "Missing Parameters")
         
End Try



		
RuleParametersOutput()
InventorVb.DocumentUpdate()
ThisApplication.ActiveView.Fit
Message 4 of 4
Benjaaamin
in reply to: nstevelmans

@nstevelmans you are a legend! Exactly what I was wanting!

 

Cheers

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

Post to forums  

Autodesk Design & Make Report