Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Scale In Title Block - No Prompted Entry, Keep Current Sheet Active

3 REPLIES 3
Reply
Message 1 of 4
wengerbryan
1785 Views, 3 Replies

Scale In Title Block - No Prompted Entry, Keep Current Sheet Active

The following iLogic code is to populate the first view scale into the drawing title block.  There are two issues with this code that I need help with.  First, it requires there to be a prompted entry text box in the title block named <SCALE>.  Is there any way to write to a textbox that is not prompted entry?  The prompt when a new drawing or sheet is created is misleading and makes users think they need to manually fill out the prompt.  Secondly, this code works on multi-sheet drawings but it concludes by making the last sheet active.  Since we are triggering this rule before save it's a nuisance to have the drawing switch sheets everytime you do a save.  Ideally, the current active sheet should remain active when the rule runs.  Can anyone help?  Here is the code:

 

For Each oSheet In ThisApplication.ActiveDocument.Sheets
    ActiveSheet=ThisDrawing.Sheet(oSheet.Name)
	If oSheet.TitleBlock Is Nothing Or oSheet.DrawingViews.count=0 Then Exit Sub
	oTitleBlock=oSheet.TitleBlock
	oTextBoxes=oTitleBlock.Definition.Sketch.TextBoxes
	For Each oTextBox In oTextBoxes
	    If oTextBox.Text="<SCALE>" Then
		    DrawingViewName=ThisApplication.ActiveDocument.ActiveSheet.DrawingViews.Item(1).Name
			oTitleBlock.SetPromptResultText(oTextBox, ActiveSheet.View(DrawingViewName).ScaleString)
		End If
	Next
Next
ThisApplication.ActiveDocument.Sheets.Item(1).Activate
InventorVb.DocumentUpdate()

 

 

Inventor 2012 SP2
Vault Collaboration 2013 SP1
Dell Precision T3500, Xeon W3503 2.4GHz, AMD FirePro V4900
Windows 7 64-bit, 8 GB RAM
3 REPLIES 3
Message 2 of 4
SBix26
in reply to: wengerbryan

As far as the active sheet issue, I don't have code for you, but the rule just needs to find out what the active sheet is when it starts, and return that sheet to active status before it finishes.

 

For the title block scale, I think the current best practice is to establish a custom iProperty to hold the scale (do this in the drawing template).  The iLogic rule then writes the scale to this iProperty, and the title block references this iProperty instead of using a prompted entry.  Works very well for us.

Sam B
Inventor 2012 Certified Professional

Please click "Accept as Solution" if this response answers your question.
-------------------------------------------------------------------------------------
Inventor Professional 2013 SP1.1 Update 2
Windows 7 Enterprise 64-bit, SP1
HP EliteBook 8770w; 8 GB RAM; Core™ i7-3720QM 2.60 GHz; Quadro K4000M
SpaceExplorer/SpaceNavigator NB, driver 3.16.2
still waiting for a foreshortened radius dimensioning tool in Drawing Manager

Message 3 of 4
wengerbryan
in reply to: SBix26

Thanks for the input, Sam.  I am aware of the "scale to iproperty" workflow, however, our scale will often vary per sheet and it does not work for us to have a master drawing scale.  The code we have works well in that it pull the scale from the first view on each sheet, it's just that the prompted entry is unnecesary and confusing.  Thanks again.

 

Bryan

Inventor 2012 SP2
Vault Collaboration 2013 SP1
Dell Precision T3500, Xeon W3503 2.4GHz, AMD FirePro V4900
Windows 7 64-bit, 8 GB RAM
Message 4 of 4
SKinzel
in reply to: wengerbryan

The following is code I got from a tutorial that I no longer have a link to.  It uses the Custom iProperty to store the scale of the base view in a sheet.  In my drawing template I've set up Sheet 1, Sheet 2 and Sheet 3 in the Sheet Formats under Drawing Resources.  the title block of each referes to its own Scale variable so that way each sheet can have a different scale.  When I add a second or third sheet I use the Sheet Format to insert the sheet.  I'm still pretty much a noob when it comes to iLogic code so I'm not sure how this differs from what was in the original post.

 

Dim odrawdoc As DrawingDocument

odrawdoc = ThisApplication.ActiveDocument

customPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties")

For i = 1 To odrawdoc.Sheets.Count

' Make sure the desired property exists

Try

      prop = customPropertySet.Item("Scale" + Str(i))

Catch

      ' Assume error means not found

      customPropertySet.Add("", "Scale" + Str(i))

End Try

Try

iProperties.Value("Custom", "Scale" + Str(i)) = odrawdoc.sheets.item(i).DrawingViews.Item(1).ScaleString

Catch

End Try

Next i

InventorVb.DocumentUpdate(

Stuart Kinzel
Inventor 2013-64bit, HP EliteBook8740w Intel Core i5CPU 2.67 GHz
8GB memory
Windows 7 64bit

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

Post to forums  

Autodesk Design & Make Report