Inventor General Discussion

Reply
Member
jestes
Posts: 4
Registered: ‎04-13-2007
Message 1 of 6 (667 Views)

Reference Drawing Sheet Number with iLogic

667 Views, 5 Replies
12-11-2012 12:01 PM

Hi,

 

Does anyone know how to reference the drawign sheet number using iLogic?  I see on the snippets on the side a way to reference the sheet name, but I only want the number.  To get the name it is ActiveSheet.Name, but ActiveSheet.Number does not work.  Getting the name give something like ASSM:1, so if there was a way to take that and subtract the colon and everything before it that would work also.  I am not a programmer, I've just taked some programs I found online and modified them a little to do what I want to do, but this is holding me back a bit.

 

Overall, I'm trying to modify the drawing view label to have a project number, referenced from the drawign iProperties, a view label, and sheet number, and then save that info in an iproperty of the part, and then reference that in the BOM so it automatically labels all of the views and fills out a column of the BOM to reference which page and view to find the parts of the assembly.  I have everything working except for the sheet number.

 

I would greatly appreciate any help.

 

Thanks,

Jeremy

*Expert Elite*
Curtis_Waguespack
Posts: 2,840
Registered: ‎03-08-2006
Message 2 of 6 (664 Views)

Re: Reference Drawing Sheet Number with iLogic

12-11-2012 12:36 PM in reply to: jestes

Hi jestes,

 

Here is an example:

 

Dim oSheet As Sheet
Dim SheetNumber as String
i = 1
For Each oSheet In ThisApplication.ActiveDocument.Sheets
SheetNumber  = Mid(oSheet.Name, InStr(1, oSheet.Name, ":") + 1)
MessageBox.Show(SheetNumber, oSheet.Name)
i=1+1
Next

Or something like this to get the active sheet only:

 

oDoc = ThisDoc.Document
SheetNumber  = Mid(oDoc.ActiveSheet.Name, InStr(1, oDoc.ActiveSheet.Name, ":") + 1)
MessageBox.Show(SheetNumber, oDoc.ActiveSheet.Name)

 

 

 

Keep in mind you might have better luck searching and asking questions of this type on the Inventor Customization forum:
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



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Member
jestes
Posts: 4
Registered: ‎04-13-2007
Message 3 of 6 (651 Views)

Re: Reference Drawing Sheet Number with iLogic

12-11-2012 01:27 PM in reply to: Curtis_Waguespack

Thanks Curtis, that worked great.  I think this will help us out a lot.

 

Jeremy

Member
jestes
Posts: 4
Registered: ‎04-13-2007
Message 4 of 6 (631 Views)

Re: Reference Drawing Sheet Number with iLogic

12-12-2012 08:32 AM in reply to: jestes

Hey Curis, I found a problem in my code I was hoping you could help me with again.  For some reason what I'm doing does not work with any parts made by the frame generator.  Everything else I've tried seems to work well.  What I want is to get a project number-view label-sheet number sent to the Status iPropertie of the part or assembly that is inside the view.  Then I can use the Status iProperty inside my view label and the BOM.  I'll attach my code below.  If you wouldn't mind looking at it I would appreciate it.  Thanks a lot, I appreciate the help.

 

Jeremy

 

'start of ilogic codeDim oDoc As DrawingDocument:  oDoc = ThisDoc.Document

Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Dim SheetNumber As String
i =1

oSheets = oDoc.Sheets


For Each oSheet In oSheets
oViews = oSheet.DrawingViews
                For Each oView In oViews
                'capture the current view label
ViewLabel = oView.Name oModelName = _ oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName Try SheetNumber =Mid(oSheet.Name, InStr(1, oSheet.Name, ":") + 1) i=1+1 iProperties.Value(oModelName, "Status", "Status") = _
iProperties.Value("Project", "Project")+"-"+ViewLabel+SheetNumber 'Send view label items to models Status iProperty
'Use Status iProperty for view label
Catch 'do nothing if error
End Try 'End If
Next Next 'end of ilogic code
*Expert Elite*
Curtis_Waguespack
Posts: 2,840
Registered: ‎03-08-2006
Message 5 of 6 (627 Views)

Re: Reference Drawing Sheet Number with iLogic

12-12-2012 09:12 AM in reply to: jestes

Hi jestes,

 

The problem is with the display name of the Frame Generator parts (and many other Content Center parts). Basically Autodesk is setting the display name as an override in their Content Center tables, and therefore your code was reading in something such as ANSI 2x2x3_16 00000009 rather then ANSI 2x2x3_16 00000009.ipt.

 

Adding a line of code to reset the display name to nothing, allows the part to return back to the default display name.

oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName = ""

 

This is the same as doing this:

 

 

Here's your updated rule.

 

 

'start of ilogic code
Dim oDoc As DrawingDocument:  oDoc = ThisDoc.Document
Dim oSheets As Sheets
Dim oSheet As Sheet
Dim oViews As DrawingViews
Dim oView As DrawingView
Dim SheetNumber As String
i =1
oSheets = oDoc.Sheets

For Each oSheet In oSheets
oViews = oSheet.DrawingViews
	For Each oView In oViews
		'capture the current view label
		ViewLabel = oView.Name
		'reset the display name 
		oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName = "" 
		'get the display name              
		oModelName = _
		oView.ReferencedDocumentDescriptor.ReferencedDocument.DisplayName
		Try
		'get the sheet number
		SheetNumber =Mid(oSheet.Name, InStr(1, oSheet.Name, ":") + 1)
		i=1+1
		iProperties.Value(oModelName, "Status", "Status") = _
		iProperties.Value("Project", "Project")+"-"+ViewLabel+SheetNumber
		'Send view label items to models Status iProperty           
		'Use Status iProperty for view label
		Catch
		'do nothing if error
		End Try
	Next
Next
'end of ilogic code

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



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Member
jestes
Posts: 4
Registered: ‎04-13-2007
Message 6 of 6 (610 Views)

Re: Reference Drawing Sheet Number with iLogic

12-12-2012 02:04 PM in reply to: Curtis_Waguespack

Thanks Curtis,

 

That fixed that, but I did run into a couple more issues.  Is there any way to make it work with iParts?  I get an error if there is an iPart on the sheet.  I might have to use a different iProperty other than Status to work with iParts because I don't see that as being on that you can update in the iPart table.  If this is not doable or very difficult I can just update these views manually.  It seems to still work for the rest of the views.

 

Also, for some reason it works fine on 2 of the machines I tried it on, but it won't work on one of our other employees machines.  It doesn't give any errors, and as far as I know it runs the program, but it just doesn't do anything.  No changes to the properties.  Any idea why it would be different on one machine?  I have the rule saved in a template, so we're both opening the exact same thing and both on Inventor 2013.  I don't think he has the newest service pack installed, so that might be it.

 

Thanks for the help, I really appreciate it.

Jeremy

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube