Passing iLogic parameter into dimension value for title block?

Passing iLogic parameter into dimension value for title block?

Anonymous
Not applicable
2,539 Views
18 Replies
Message 1 of 19

Passing iLogic parameter into dimension value for title block?

Anonymous
Not applicable

Has anyone done this?

 

 

0 Likes
Accepted solutions (3)
2,540 Views
18 Replies
Replies (18)
Message 2 of 19

mcgyvr
Consultant
Consultant

Possibly.. can you be more specific?

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 3 of 19

Anonymous
Not applicable

Sure. I'm designing a title block that spans an entire sheet height within defined borders, with a consistent width.

 

I want the titleblock to remain the same width for both ANSI D and Arch D (Easy!), but I want the height of the "empty space" to change by some delta according to the (sheet height - the border gap on both sides). (the not so easy part)

 

I want to determine what the sheet size is based on an iLogic parameter, and pass that data into some dimension parameter within the title block definition, so I can adjust the size of two lines relative to the maximum sheet height and the borders.

 

 

0 Likes
Message 4 of 19

mcgyvr
Consultant
Consultant

I'm not sure.. Don't think so as title block definitions don't support parameters for dimensions..

I would just use 2 title blocks and call it a day.. 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 5 of 19

Anonymous
Not applicable

I think it does because you can set dimension parameter values to others within the titleblock. When you edit a dimension, you can totally use "=d3", for example.

 

 

0 Likes
Message 6 of 19

Anonymous
Not applicable

@mcgyvr wrote:

I'm not sure.. Don't think so as title block definitions don't support parameters for dimensions..

I would just use 2 title blocks and call it a day.. 



I think it does because you can set dimension parameter values to others within the titleblock. When you edit a dimension, you can totally use "=d3", for example.

 

 

0 Likes
Message 7 of 19

mcgyvr
Consultant
Consultant

@Anonymous wrote:

@mcgyvr wrote:

I'm not sure.. Don't think so as title block definitions don't support parameters for dimensions..

I would just use 2 title blocks and call it a day.. 



I think it does because you can set dimension parameter values to others within the titleblock. When you edit a dimension, you can totally use "=d3", for example.

 

 


I meant user or named parameters..

Yes you can do = d3 but you can't do "BlockWidth=1" like you can do in regular Inventor files..

 

 

I would still use 2 title blocks and call it done  (I'm sure you have spent far more time investigating this than if you were to just make the second block and call it a day).. I personally see no point in writing custom code to handle something that more than likely will never be modified again.. Once you have your title blocks set up there is a very slim chance they will be modified again..

Sure it can happen in certain cases but tackle that when/if it ever happens...



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
0 Likes
Message 8 of 19

Curtis_Waguespack
Consultant
Consultant
Accepted solution

HI RobertWK,

 

This can be done using the API TitleBlockDefinition.Sketch property, attached is a quick working example created with Inventor 2015.

 

Also just as a tip, you can search and ask programming questions of this type on the Inventor Customization forum too:
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oTitleBlockDef As TitleBlockDefinition
oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item(1)

Dim oSketch As DrawingSketch
oTitleBlockDef.Edit(oSketch)

Dim oDim As DimensionConstraint

For Each oDim In oSketch.DimensionConstraints
  If oDim.Parameter.Name = "d1" Then
  	'toggle the dimension value ( in inches)
  	If oDim.Parameter.Value = 2 * 2.54 Then
		oDim.Parameter.Value = 3 * 2.54
	Else
		oDim.Parameter.Value = 2 * 2.54
	End If			
  End If
Next

oTitleBlockDef.ExitEdit(True)

EESignature

Message 9 of 19

Anonymous
Not applicable

@Curtis_Waguespack wrote:

HI RobertWK,

 

This can be done using the API TitleBlockDefinition.Sketch property, attached is a quick working example created with Inventor 2015.

 

... (code) ...

 

 


Does there have to be a rule, trigger that fires this?

0 Likes
Message 10 of 19

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi RobertWK,

 

I would use a form to change the sheet size and trigger the rule. See the attached example file (Inventor 2015).

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

If SheetSizeList = "D Arch" Then
	ActiveSheet.ChangeSize("24 x 36 (inches)", MoveBorderItems := True)
ElseIf SheetSizeList = "D ANSI" Then
	ActiveSheet.ChangeSize("D", MoveBorderItems := True)
ElseIf SheetSizeList = "C Size" Then
	ActiveSheet.ChangeSize("C", MoveBorderItems := True)
ElseIf SheetSizeList = "B Size" Then
	ActiveSheet.ChangeSize("B", MoveBorderItems := True)
ElseIf SheetSizeList = "A Size" Then
	ActiveSheet.ChangeSize("A", MoveBorderItems := True)
End If

''use this line to report SheetSizeList for testing
'InputBox("Sheet Size Is:", "iLogic",SheetSizeList )

''use this line to report ActiveSheet.Size for testing
'InputBox("Sheet Size Is:", "iLogic",ActiveSheet.Size )


Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oTitleBlockDef As TitleBlockDefinition
oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item(1)

Dim oSketch As DrawingSketch
oTitleBlockDef.Edit(oSketch)

Dim oDim As DimensionConstraint

oValue = ActiveSheet.Height - (0.125 in * 2) 'where 0.125 in = the border margin

For Each oDim In oSketch.DimensionConstraints
  If oDim.Parameter.Name = "d0" Then
	oDim.Parameter.Value = oValue * 2.54 '2.54 coverts the value to inches			
  End If
Next

oTitleBlockDef.ExitEdit(True)

'zoom all
ThisApplication.ActiveView.Fit

EESignature

Message 11 of 19

Anonymous
Not applicable

Curtis, 

 

You are amazing!

 

 

0 Likes
Message 12 of 19

Anonymous
Not applicable

I put together this bit, but it seems to be causing a warning:

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oTitleBlockDef As TitleBlockDefinition
oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item(1)

Dim oSketch As DrawingSketch
oTitleBlockDef.Edit(oSketch)

Dim oDim As DimensionConstraint

If ActiveSheet.Height = 11 And oTitleBlockDef = "A-B" Then
    oDim.Parameter.Value("d0") = (8.5 - .25 - .25 - .75 - (.25*5))
Else If ActiveSheet.Height = 17 And oTitleBlockDef = "A-B" Then
    oDim.Parameter.Value("d0") = (11 - .25 - .25 - .75 - (.25 * 5))
End If


oTitleBlockDef.ExitEdit(True)

 

Error in rule: INSERT_BLOCK, in document: title_development.idw

Unable to cast COM object of type 'System.__ComObject' to class type 'System.String'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.

 

Where can I find documentation about objects and functions for the Inventor iLogic api/sdk?

 

 

0 Likes
Message 13 of 19

Curtis_Waguespack
Consultant
Consultant

Hi RobertWK,

 

Does your title block have prompted entries in it?

 

API reference info:

http://inventortrenches.blogspot.com/2013/10/ilogic-how-to-learn-inventors.html

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 14 of 19

Anonymous
Not applicable

Not yet, but it will, eventually.

 

 

0 Likes
Message 15 of 19

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi RobertWK,

 

A couple of things. My earlier examples found the titleblock by Item number (ex: DrawDoc.TitleBlockDefinitions.Item(1), but if you intend to call it by name, you can just set the oTitleBlockDef to do so as in the example below.

 

Unfortunately, it doesn't appear that you can do the same for the dimension (unless I missed it), so I've used an For Each to find "d0"

 

Also, the ActiveSheet.Height comes in as Inches (it's an iLogic call) , but the Parameter Value (Inventor API call) uses Inventor's internal units of cm's so a conversion is needed.

 

And lastly, I tested this with a prompted entry in the title block and it doesn't seem to cause an issue, so you can ignore that question from earlier.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument

Dim oTitleBlockDef As TitleBlockDefinition
oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item("A-B")

Dim oSketch As DrawingSketch
oTitleBlockDef.Edit(oSketch)

Dim oDim As DimensionConstraint

'find d0
For Each oDim In oSketch.DimensionConstraints
	If oDim.Parameter.Name = "d0" Then
		Exit For
	End If
Next

If ActiveSheet.Height = 11  Then
    oDim.Parameter.Value = (8.5 - 0.25  - 0.25  - 0.75 - (0.25*5)) * 2.54
Else If ActiveSheet.Height = 17 Then
    oDim.Parameter.Value = (11 - 0.25 - 0.25 - 0.75 - (0.25 * 5)) * 2.54
End If

oTitleBlockDef.ExitEdit(True)

 

EESignature

Message 16 of 19

Anonymous
Not applicable

Thanks a ton 🙂

 

This has been an immeasurable amount of help.

 

0 Likes
Message 17 of 19

Anonymous
Not applicable

Nevermind. Fixed it with Case.

 

0 Likes
Message 18 of 19

Anonymous
Not applicable

Curtis,


The for loop to find the dimension of 'd0' is failing to run all the time, probably because of an indexing problem or some kind of return value. I have to run the rule multiple times for it to 'fire'.

 

Is there a way to directly address the 'd0' dimension without having to find it?

0 Likes
Message 19 of 19

Curtis_Waguespack
Consultant
Consultant

Hi RobertWK,

 

If you know that it is always going to be d0 (i.e. the first dimension in the sketch) then I think you can just use:

 

oDim = oSketch.DimensionConstraints.Item(1)

 

As this will designate the first dimension constraint / parameter as oDim

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes