Hello together,
how could I synchronize my drawing with the referenced part?
I have a "User Defined Propertie" called "RBMATNO" in the part and in the drawing.
Thank you very much
Georg
Hi Georg,
You should be able to do something like this - e.g. in VBA:
Sub SynchronizeUserParam() Dim dwg As DrawingDocument Set dwg = ThisApplication.Documents(2) Dim part As PartDocument Set part = ThisApplication.Documents(1) Dim param As Variant param = dwg.Parameters("RBMATNO").Expression part.ComponentDefinition.Parameters("RBMATNO").Expression = param End Sub
Cheers,
oops... not sure know why I thought you said Parameters - which my code was about.
This is how you synchronize an iProperty inside "User Defined Properties"
Sub SynchronizeiProperty() Dim dwg As DrawingDocument Set dwg = ThisApplication.Documents(1) Dim part As PartDocument Set part = ThisApplication.Documents(2) ' Accessing "User Defined Properties" set Dim dps As PropertySet Set dps = dwg.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") Dim pps As PropertySet Set pps = part.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") Dim param As Variant param = dps("MyProperty").Expression pps("MyProperty").Expression = param End Sub
Adam
Will this work in iLogic?
If not, can it be done in iLogic?
If so, how?
Will this work in Inv2015?
Hi,
You just have to convert it to iLogic compatible code:
http://adndevblog.typepad.com/manufacturing/2015/11/convert-vba-to-net-ilogic.html
Cheers,
Hi, you can use this:
oModelRef = ThisDrawing.Document.Sheets.Item(1).DrawingViews.Item(1).ReferencedFile
ModelFileName = oModelRef.FullFileName
oModelDoc = ThisApplication.Documents.Open(ModelFileName, 0)
iProperties.Value("Custom", "RBMATNO") = oModelDoc.PropertySets.Item("User Defined Properties").Item("RBMATNO").Value
Or you could just have Inventor do this for you and not worry with ilogic and VBA.
Create the custom Iproperty on the drawing template.
Then got to Tools --> Document Settings--> Drawing Tab
At the bottom you will see Copy Model iproperty Settings click on that and put a check in the two check boxes.
As shown in one of the sample codes above, you can find out which document is referenced by a given view on a given sheet.
So you can just iterate through the sheets and the views on them and then access the iproperties of those doucments and then do with them whatever you need to.
Hi I am trying to do something very similar, We have profile drawings (sheets for laser cutting) on the 2nd last page (eg 15th sheet) of every drawing set. The page number of the sheet is manually written onto i-properties of each part.
Whenever there is an additional sub assembly added we end up manually changing the iproperties by incrementing by the additional pages we added. ie if we added 2 pages of subassembly to the drawing sets the new profile page will be moved to sheet 17.
i am stuck where i need to pass the page number to part, i am not getting the right syntax , may be you might be able to help me here.TIA.
regerds
Mithun
Sub Sheet_NO_2_parts()
Dim oSSet As SelectSet
Dim dwodoc As DrawingDocument
Dim tmpsheet As Sheet
Dim PART_NAME As PartDocument
Set PART_NAME = ThisApplication.Documents(2)
Set dwodoc = ThisApplication.ActiveDocument
Set tmpsheet = dwodoc.ActiveSheet
Set oSSet = dwodoc.SelectSetIf oSSet.Count = 0 Then
MsgBox "PLEASE SELECT A VIEW"
Exit Sub
End If
Dim oView As DrawingView
Set oView = oSSet.Item(1)If oView = kDrawingViewObject Then
Set pps = PART_NAME.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
pps("Description").Expression = "Sheet-15"
Else
MsgBox "WORKS ONLY ON DRAWING FILES"End If
End Sub
Hi,
this my version.
Dim oApp As Application
Dim oDD As DrawingDocument
Dim oSht As Sheet
Dim oDV As DrawingView
Dim oReffDoc As Document
Dim oDwgPropSet As PropertySet
Dim oReffPropSet As PropertySet
Dim oDwgCustProp As Property
Dim oReffCustProp As Property
oApp = ThisApplication
oDD = oApp.ActiveDocument
oSht = oDD.ActiveSheet
oDV = oSht.DrawingViews(1)
oReffDoc = oDV.ReferencedDocumentDescriptor.ReferencedDocument
oDwgPropSet = oDD.PropertySets("User Defined Properties")
oReffPropSet = oReffDoc.PropertySets("User Defined Properties")
oDwgCustProp = oDwgPropSet("RBMATNO")
oReffCustProp = oReffPropSet("RBMATNO")
oDwgCustProp.Value = oReffCustProp.Value
Hi.
I have used this iLogic codes.
To get iProperties from model to drawing.
If (ThisDrawing.ModelDocument Is Nothing) Then Return modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) 'read the values from the Custom iProperties in the part file 'and apply them to the Custom iProperties with the same name in the drawing iProperties.Value("Custom", "Header 1") = iProperties.Value(modelName, "Custom", "Header 1") iProperties.Value("Project", "Part Number")=iProperties.Value(modelName, "Project", "Part Number") iProperties.Value("Project", "Project")=iProperties.Value(modelName, "Project", "Project") iProperties.Value("Summary", "Title")=iProperties.Value(modelName, "Summary", "Title")
And this to send iProperties from the drawing to the model.
' Set a reference to the drawing document. ' This assumes a drawing document is active. Dim oDrawDoc As DrawingDocument oDrawDoc = ThisApplication.ActiveDocument ' Set a reference to the active sheet. Dim oSheet As Sheet oSheet = oDrawDoc.ActiveSheet 'Get the name Of the first model in the drawing modelName = IO.Path.GetFileName(ThisDrawing.ModelDocument.FullFileName) iProperties.Value(modelName, "Custom", "Header 1") = iProperties.Value("Custom", "Header 1") iProperties.Value(modelName, "Project", "Part Number")=iProperties.Value("Project", "Part Number") iProperties.Value(modelName, "Project", "Project")=iProperties.Value("Project", "Project") iProperties.Value(modelName, "Summary", "Title")=iProperties.Value("Summary", "Title") iLogicVb.UpdateWhenDone = True
Easy to add or remove iProperties you want to sync.
@andrescastellanosint Could explain the context of your request? The rule is intended to pick up the first model iproperties and apply to the title block with the same title block in all the drawing sheets. If you want to point to a different view you can use the longer API method shown here
and change the view number. Common practice is to have view 1 as the model reference.
Hello, I am trying to extract information from the title block and add it to the name of the views. This rule only modifies one view for me.
I would like to be able to make a loop and be able to change the name of all the views.
In this case because the topic is very different I would suggest you to create a new post and check out those sample links.
HI, thanks for the info, but I really need to get the property "Keywords" of Drawing not the models, and then copy it to the models property of all views.
I think this will do what you are asking.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
oKeywords = iProperties.Value("Summary", "Keywords") Dim oDoc As DrawingDocument oDoc = ThisDrawing.Document Dim oModelDoc As Document For Each oSheet In oDoc.Sheets oSheet.activate For Each oView In oSheet.DrawingViews oModelDoc = ThisDrawing.ActiveSheet.View(oView.Name).ModelDocument oModelDoc.PropertySets.Item(1).Item("Keywords").Value = oKeywords Next Next