Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Drawing rule does not work if components are reference

tmathieson
Advocate

Drawing rule does not work if components are reference

tmathieson
Advocate
Advocate

Morning All, hope the weekend was good.

 

i am having an issue with an iLogic rule i have written to add center lines and dimensions  to a drawing view of the assembly.  this rule works fine if the components are "default", but if they are set to 'reference', the centerlines do not get inserted.  i can go into the drawing view and manually add them, and if i change the components back to default, they are added...  there must be something I'm missing.  i can dimension to points on the reference part, can manually add centerlines (1 at a time, auto centerline option does not work), so why does my rule not work on reference parts/

 

Is there some setting i'm missing, or will i need to set my components to default, run rule, and then set it back manually?

 

thanks for any insight into this!

0 Likes
Reply
394 Views
7 Replies
Replies (7)

WCrihfield
Mentor
Mentor

Hi @tmathieson.  I don't know what your code looks like, but it sounds like you may have to loop through the assembly's components, check if they are set to 'reference', and if so, use DrawingView.SetIncludeStatus and/or DrawingView.SetVisibility methods to include the needed geometry from them needed for your centerpoints/dimensions.  Just one thought.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

tmathieson
Advocate
Advocate

thanks @WCrihfield !  (as Always ;^}).

 

this is what i was missing!  had seen these statements in some of the posts i looked at, but missed the connection to reference docs.  back to the editor!!

 

thanks again!!

0 Likes

tmathieson
Advocate
Advocate

so i've been working on this, but to no success.  i can find  the components i want, but cannot get them to add to SetIncludeStatus. still struggling with the component proxy. if these components are in the top level assembly, (not a sub), do i need the proxy?  i have tried it with and without.... is it something in my assignment line "oDef.Occurrences.Item(z)" ?

 

 

Dim oSubCompProxy As ComponentOccurrenceProxy		
Dim oDef As AssemblyComponentDefinition = oModel.ComponentDefinition
Dim oOcc2 As ComponentOccurrence
z=1
For Each oOcc As ComponentOccurrence In oOccs
	If oView.GetVisibility(oOcc) = True
		Logger.Debug(oOcc.Name)
		oOcc2 = oDef.Occurrences.Item(z)
		Logger.Debug(oOcc2.Name & "...show me")
		oSubCompProxy = oDef.Occurrences.Item(z)
		oView.SetIncludeStatus(oSubCompProxy, True)
	End If
	z=z+1
Next

again, thanks for any help or inisght...

0 Likes

A.Acheson
Mentor
Mentor

Here is a post that should help you. Proxies need to be created from an occurrence. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan

WCrihfield
Mentor
Mentor

Hi @tmathieson.  I assume this is not all of the code, because I do not see where the variables 'oModel', 'oOccs', or 'oView' are declared. 

  The 'top level' components in any assembly are just regular ComponentOccurrence objects, and all other components at lower levels are all ComponentOccurrenceProxy type objects.  The ComponentOccurrenceProxy Type is derived from the ComponentOccurrence Type (Class), so variable declared as the non-proxy type can hold the proxy type object, but I don't think that a variable declared as the proxy type can hold a non-proxy type object.  Similar is true for other types of things.  If any work feature (WorkAxis, WorkPlane, WorkPoint) or sketches are created directly in the top assembly, they are regular ones, but all of them that exist within components (even top level components) are all proxy versions.  If you use the Pick method to select any geometry in the main assembly, other than the work features/sketches that were created directly in the top assembly, everything you Pick will already be a proxy type, because all geometry belongs to the components, not the main assembly.  However, if not using the Pick command, and using ComponentDefinition resources to get a reference to geometry in the assembly, you will most likely have to use the CreateGeometryProxy method of the component that the geometry belongs to, in order to get a reference to that geometry within the 'parent' model space.  If the geometry, or its owning component are multiple levels deep, you will need to do this for each level up, until your proxy geometry is in the context of the main assembly, if you want to be able to use that geometry for things like measurements, constraints, or top level feature involvement.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

tmathieson
Advocate
Advocate

hI @WCrihfield , @A.Acheson .   again, thanks for your attention to this.  so the components i am trying to include in the drawing view at top level assembly, so i do not need a proxy?

 

@WCrihfield, here is my code as i have it now... i get  "unknown error" on line 52, the "oView.SetIncludeStatus(oOcc2.Name, True)" statement....

 

'
' CODE TO ADD PLATE LABELS AND MARKS ON S01
'
Dim oDDoc As DrawingDocument = ThisDrawing.Document
ActiveSheet = ThisDrawing.Sheet("S01:5")
Dim oSheet As Sheet = oDDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)  '"PROFILE"
Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oGeneralNotes As GeneralNotes = oSheet.DrawingNotes.GeneralNotes
Dim oOccs As ComponentOccurrences = oModel.ComponentDefinition.Occurrences
Dim oGeneralDIMS As GeneralDimensions = oSheet.DrawingDimensions.GeneralDimensions

oView.ViewStyle = 32257
InventorVb.DocumentUpdate()

Dim oDef As AssemblyComponentDefinition = oModel.ComponentDefinition
Dim oOcc2 As ComponentOccurrence	
For Each oOcc As ComponentOccurrence In oOccs
'	If oview.GetVisibility(oOcc) = True
'		'Logger.Debug(oOcc.Name)
'		oOcc2 = oDef.Occurrences.ItemByName(oOcc.Name)
'		Logger.Debug(oOcc2.Name & "...show me")
'		oView.SetIncludeStatus(oOcc2.Name, True)
'	End If
next

 

0 Likes

WCrihfield
Mentor
Mentor

hI @tmathieson.  Change this:

oView.SetIncludeStatus(oOcc2.Name, True)

...to this:

oView.SetIncludeStatus(oOcc2, True)

That method is not looking or a name (String), it is looking for an object from model space as input.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes