Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Identify beam and continue rule otherwise exit

Benjaaamin
Enthusiast

Identify beam and continue rule otherwise exit

Benjaaamin
Enthusiast
Enthusiast

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!

 

0 Likes
Reply
Accepted solutions (1)
240 Views
3 Replies
Replies (3)

Michael.Navara
Advisor
Advisor

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.

0 Likes

nstevelmans
Advocate
Advocate
Accepted solution

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
0 Likes

Benjaaamin
Enthusiast
Enthusiast

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

 

Cheers

0 Likes

Type a product name