Dimension Arrangement with Ilogic - Stacking of Linear Dimensions

Dimension Arrangement with Ilogic - Stacking of Linear Dimensions

drafting4KGWTN
Contributor Contributor
294 Views
5 Replies
Message 1 of 6

Dimension Arrangement with Ilogic - Stacking of Linear Dimensions

drafting4KGWTN
Contributor
Contributor

Hi all, long time lurker - 1st time poster

 

I've been experimenting with Ilogic code since i started with my new company, and from the forums on here i've mashed together bits and pieces to arrange dimensions (exclusive of angular) how we need for detailing (we don't really use chain or baseline and only ordinate sometimes). But lately I'm coming across an issue that I'd like to sort out.

 

current resultcurrent result

 

 

desired resultdesired result

 

The 1st pic is showing what i get currently with the code I'm using, the 2nd pic is showing what I want to achieve.

 

please see below for code:-

''-------

' Set a reference to the active drawing document
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

' Get the collection of dimensions on the active sheet.
Dim oDimensions As DrawingDimensions
oDimensions = oDrawDoc.ActiveSheet.DrawingDimensions

Dim oDrawDim As DrawingDimension

' Iterate over all dimensions in the drawing and
' center them if they are linear or angular.
For Each oDrawDim In oDimensions
    If TypeOf oDrawDim Is LinearGeneralDimension Then
	 
   End If
Next

' Get a reference to the select set and clear it.
Dim oSelectSet As SelectSet
oSelectSet = oDrawDoc.SelectSet
oSelectSet.Clear

' Add each dimension to the select set to select them.
For Each oDrawDim In oDimensions
	 If TypeOf oDrawDim Is LinearGeneralDimension Then
	    oSelectSet.Select(oDrawDim) 
	End If
Next

' Get the CommandManager object.
Dim oCommandMgr As CommandManager
oCommandMgr = ThisApplication.CommandManager

' Get control definition for the arrange dimensions command.
Dim oControlDef As ControlDefinition
 oControlDef = oCommandMgr.ControlDefinitions.Item("DrawingArrangeDimensionsCmd")

' Execute the command.
Call oControlDef.Execute

 

Not really well-versed in this yet, so any help would be appreciated

(apologies if this is in the wrong section or previously addressed)

 

 

 

 

0 Likes
295 Views
5 Replies
Replies (5)
Message 2 of 6

marcin_otręba
Advisor
Advisor

maybe try to use arrange method :

 

Dim dimensions As ObjectCollection = g_inventorApplication.TransientObjects.CreateObjectCollection
For Each drawDim  As DrawingDimension In odraw.ActiveSheet.DrawingDimensions
    drawDim.CenterText()                
    Call dimensions.Add(drawDim)
Next
Call odraw.ActiveSheet.DrawingDimensions.Arrange(dimensions)

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 3 of 6

drafting4KGWTN
Contributor
Contributor

no love from that one mate, throwing up this error

 

HqczZGP3I2.jpg

0 Likes
Message 4 of 6

jnowel
Advocate
Advocate

Try this.

 

I do have additional layers for other dimensions to create some sort of exclusion (since I'm selecting all dimensions on current sheet)
Dimension Off-Center = Those I don't want to be centered anymore, but want to be "Arranged"

Dimension Off-Center + Aligned = Those not to be centered nor arranged

Dimension Aligned = Those to be centered but not "Arranged"

 

jnowel_0-1728609943742.png

Sub Main
	
	'On Error Resume Next

	Dim oDoc As Document = ThisApplication.ActiveDocument
	If Not oDoc.DocumentType = kDrawingDocumentObject Then Exit Sub
		
	Dim oSheet As Sheet = oDoc.ActiveSheet
	
	Dim oView As DrawingView

    Dim oDrawingDim As DrawingDimension
    Dim oDrawingDims As DrawingDimensions
    Dim oDimsToBeArranged As ObjectCollection

	'For Each oSheet As Sheet In oDoc.Sheets
		
	    oDrawingDimensions = oSheet.DrawingDimensions
	    oDimsToBeArranged = ThisApplication.TransientObjects.CreateObjectCollection

		For Each oDrawingDim In oDrawingDimensions
			
			If TypeOf oDrawingDim Is LinearGeneralDimension Then
	
				If Not (oDrawingDim.Layer.Name = "Dimension Off Center" Or  oDrawingDim.Layer.Name = "Dimension Off Center + Aligned") Then
					'Only center those not indicated as off-center
					oDrawingDim.CenterText
				End If
				
				If Not (oDrawingDim.Layer.Name = "Dimension Aligned" Or oDrawingDim.Layer.Name = "Dimension Off Center + Aligned") Then
					oDimsToBeArranged.Add(oDrawingDim)
				End If
				
			ElseIf TypeOf oDrawingDim Is AngularGeneralDimension Then
				
				If Not (oDrawingDim.Layer.Name = "Dimension Off Center" Or oDrawingDim.Layer.Name = "Dimension Off Center + Aligned") Then
					oDrawingDim.CenterText
				End If
		
			End If
	    Next
		
		Call oDrawingDimensions.Arrange(oDimsToBeArranged)
		
	'Next
	
End Sub

 

0 Likes
Message 5 of 6

marcin_otręba
Advisor
Advisor

sorry, i had impression after looking at code you provided that one loop will be enough for you. 

this is loop from addin so inventor was declared as g_inventorapplication. in illogic jut use

ThisApplication

instead.

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 6 of 6

drafting4KGWTN
Contributor
Contributor

This one worked in terms of excluding dimensions, but not exactly what I'm looking for sorry. Would there be a way to write the code to sort the stacking of dimensions via layers?

 

dim arrangement layer stacking.jpg

0 Likes