I am working with Automation for dimensions in a drawing.

I am working with Automation for dimensions in a drawing.

jarle_oudalstoelEN4BR
Contributor Contributor
572 Views
4 Replies
Message 1 of 5

I am working with Automation for dimensions in a drawing.

jarle_oudalstoelEN4BR
Contributor
Contributor

I am using iLogic to place dimension's in a drawing and this all works good as long as the part is in the assembly or placed by itself. 

 

The problem I am having is that the part I'm trying to get the intent from is in a sub assembly. 

I don't know how I can get down down one more level to get the surface intent I'm looking for.

 

Below is the rule I have so far.  

 

'-----THIS RULE IS FOR THE DIMENSIONS, CENTER MARKS & BALLOONS FOR SHEET SINGLE SLEEVE GASKET:4

'---THIS IS TO DEFINE THE SHEET THE RULES APPLY TO. 
Dim SSGSheet = ThisDrawing.Sheets.ItemByName("SINGLE SLEEVE GASKET:4")
Dim genDims = SSGSheet.DrawingDimensions.GeneralDimensions
Dim holeThreadNotes = SSGSheet.DrawingNotes.HoleThreadNotes
	
'-----THIS IS TO DEFINE THE DIMENSIONS NAMES AND NUMBERS
'[
'---IT'S DEFINED BY A TEXT WITH AN AUTOMATIC NUMBER. 
Dim LDIMNAME As String = ("STP LINDIM ")  	'---THIS IS THE NAME OF THE LINEAR DIMENSIONS
Dim LDIMNUMBER As Integer = 0				'---THIS IS THE COUNTER FOR THE LINEAR DIMENSION NUMBER
Dim HDIMNAME As String = ("STP HDIM")		'---THIS IS THE NAME OF THE HOLE DIMENSIONS
Dim HDIMNUMBER As Integer = 0				'---THIS IS THE COUNTER FOR THE HOLE DIMENSION NUMBER
Dim RDIMNAME As String = ("STP RDIM")		'---THIS IS THE NAME OF THE RADIUS DIMENSIONS
Dim RDIMNUMBER As Integer = 0				'---THIS IS THE COUNTER FOR THE RADIUS DIMENSION NUMBER
Dim HTNNAME As String = ("STP HTNDIM")		'---THIS IS THE NAME OF THE HOLE THREAD NOTE DIMENSIONS
Dim HTNNUMBER As Integer = 0				'---THIS IS THE COUNTER FOR THE HOLE THREAD NOTE NUMBER
Dim ADIMNAME As String = ("STP AINDIM ")  	'---THIS IS THE NAME OF THE ANGULAR DIMENSIONS
Dim ADIMNUMBER As Integer = 0				'---THIS IS THE COUNTER FOR THE ANGULAR DIMENSION NUMBER
']

'---THIS IS TO DEFINE THE DIMENSION STYLES USED WHEN PLACING DIMENSIONS. 
'[
Dim oDrawDoc As DrawingDocument = ThisDoc.Document
Dim oSheet As Sheet = oDrawDoc.ActiveSheet
Dim oStylesMgr As DrawingStylesManager = oDrawDoc.StylesManager    

'get the reference to the target dimension style (by name)
Dim oNewStyle As DimensionStyle = oStylesMgr.DimensionStyles.Item("HMT DEFAULT")			'---THIS IS THE NORMAL DIM STYLE
Dim oNewStyle01 As DimensionStyle = oStylesMgr.DimensionStyles.Item("RAD 2x")				'---THIS HAS THE PREFIX 2x 

']

'-----THIS IS TO DEFINE ALL THE DIMENSIONS, CENTER MARK & BALLONS FOR VIEW A06.001.004
'[
	Dim VIEW = SSGSheet.DrawingViews.ItemByName("GASKET")	'---THIS IS THE VIEW NAME IN THE SHEET
	Dim PART As String = ("1 PIPE SLIDE GASKET")			'---THIS IS THE INSTANT NAME OF THE PART IN THE VIEW
	Dim SUBASS As String = ("1 PIPE SLEEVE")				'---THIS IS THE SUBASSEMBLY INSTANCE NAME

	'---THIS IS ALL THE LINEAR DIMENSIONS ON THE VIEW A06.001.004
	'[
	Dim SP01 = VIEW.GetIntent(PART, "OD")
		HDIMNUMBER = HDIMNUMBER + 1
	Dim linDim = genDims.AddDiameter(HDIMNAME & HDIMNUMBER, VIEW.SheetPoint(1.0, 1.0), SP01)

The issue is when I'm getting the INTENT. I can only reference a part. I am referring to the part by it's instant name in the model tree. This works great normally but as this part is in a sub-assembly I can not get to it. 

 

If someone has some tips or tricks to solve this the help would be highly appreciated. 

 

Jarle

 

0 Likes
Accepted solutions (1)
573 Views
4 Replies
Replies (4)
Message 2 of 5

WCrihfield
Mentor
Mentor

Hi @jarle_oudalstoelEN4BR.  I don't really do much dimensioning in drawings by code, but generally understand the process.  It sounds to me like you will need to first get that lower level component occurrence object directly, then use that to get access to the 'proxy' of some geometry of that part.  That first proxy you get will still be in the context of the sub assembly though, instead of in the context of the 'main' assembly, so that proxy portion of the code will need two steps.  The second step will use that proxy in the sub assembly to get the proxy that is then in the context of the main assembly, so you can use it for geometry intent purposes.

 

I will post some example code below that is just for describing the process needed in a case like this, using some generic component names, and just the first face found in the bottom part, as an example.  It first uses an iLogic tool called 'MakePath', which lets you specify the 'path' of the lower level component occurrence that you want to target.  Then uses that 'path' to get that occurrence object.  Then uses that occurrence object to get a Face from, and later to get the 'proxy' of that face that is in the sub-assembly.  Then gets the sub assembly occurrence, so we can use that to get access to the 'proxy' of that first proxy that will be in the context of the 'main' assembly.  Once we have that top level proxy, we can use that for out 'intent', for the dimension.  You will of course have to take that 'code plan/process' and adapt it into your own as you see fit though.  I hope you understand what is going on there, and hope this helps some.

'specify top level sub assembly occurrence name (as seen in model browser) first
'then specify next lower occurrence name after a comma separator,
'until the lowest level occurrens name that you want to specify is included
Dim sOcc1Path As ArrayList = MakePath("SubAssem1:1", "Part2:1")
'then use that 'sCompPath' variable to specify which component you want to work with
Dim oOcc1 As ComponentOccurrence = Component.InventorComponent(sOcc1Path)
'now get a proxy from that lower level occurrence that is in the sub assembly
'in this case a specific Face (which will be a FaceProxy)
Dim oOcc1Face1 As Face = oOcc1.Definition.SurfaceBodies.Faces.Item(1)
'prepare a variable to hold the face proxy
Dim oOcc1Face1ProxyInSubAsm As Object = Nothing 'or As FaceProxy, if original was a Face
'now use this method of the 'owning' occurrence to get the proxy
oOcc1.CreateGeometryProxy(oOcc1Face1, oOcc1Face1ProxyInSubAsm)
'now get the proxy of that proxy that is in the 'main' assembly
Dim oSubAsm1Occ As ComponentOccurrence = Component.InventorComponent("SubAssem1:1")
'same scenario as before, but using this sub assembly occurrence
Dim oOcc1Face1ProxyInMainAsm As Object = Nothing
oSubAsm1Occ.CreateGeometryProxy(oOcc1Face1ProxyInSubAsm, oOcc1Face1ProxyInMainAsm)
'now you can use that FaceProxy that is in the context of the main assembly 'oOcc1Face1ProxyInMainAsm'
'for getting the needed GeometryIntent for your dimension

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

JMGunnar
Collaborator
Collaborator
Accepted solution

 

You can write this code with {} too get path too subassemblies 

see example

 

JM Gunnar

@jarle_oudalstoelEN4BR 

 

Dim SP01 = VIEW.GetIntent({"1 PIPE SLEEVE","1 PIPE SLIDE GASKET"},"OD")

 

 

 

 

Dim VIEW = SSGSheet.DrawingViews.ItemByName("GASKET")	'---THIS IS THE VIEW NAME IN THE SHEET
	Dim PART As String = ("1 PIPE SLIDE GASKET")			'---THIS IS THE INSTANT NAME OF THE PART IN THE VIEW
	Dim SUBASS As String = ("1 PIPE SLEEVE")				'---THIS IS THE SUBASSEMBLY INSTANCE NAME

	'---THIS IS ALL THE LINEAR DIMENSIONS ON THE VIEW A06.001.004
	'[
	Dim SP01 = VIEW.GetIntent(PART, "OD")

 

 

Message 4 of 5

jarle_oudalstoelEN4BR
Contributor
Contributor

@JMGunnar thank you for helping me with this. That worked great. 

 

Jarle

0 Likes
Message 5 of 5

Stakin
Collaborator
Collaborator

You can use 

ComponentOccurrenceProxy.OccurrencePath() As ComponentOccurrencesEnumerator 

ComponentOccurrence.OccurrencePath() As ComponentOccurrencesEnumerator 

ComponentOccurrenceProxy.OccurrencePath.Cast(of String).ToArray

ComponentOccurrence.OccurrencePath.Cast(of String).ToArray

will return 

{"1 PIPE SLEEVE","1 PIPE SLIDE GASKET"}