Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic of the drawing in the model

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
Anonymous
766 Views, 7 Replies

iLogic of the drawing in the model

Hello everybody,





I would a iLogic - to map values from the drawing in the model - code need two custom iProperties.





<PF_DRWNO> & <PF_DOC_REV>.





Does somebody has any idea?





MFG





Sascha May

7 REPLIES 7
Message 2 of 8
Dennis.Ossadnik
in reply to: Anonymous

Hi Sascha,

 

just let me check if I got it right.

You have two properties in the drawing. PF_DRWNO and PF_DOC_REV

Now you want to push these properties to the part file? As custom iProperties in the part file?



Dennis Ossadnik
Senior Technical Support Specialist
Message 3 of 8
Anonymous
in reply to: Dennis.Ossadnik

Hallo Dennis,

ja ich würde gerne mit einer iLogoc Regel diese zwei Werte von der Zeichnung in das Modell übertragen (PF_DRWNO and PF_DOC_REV).

Grüße

Sascha

 

Hello Dennis,
yes I would like to transfer these two values from the drawing in the model with an iLogic rule (PF_DRWNO and PF_DOC_REV).
greetings
Sascha

Message 4 of 8
Owner2229
in reply to: Anonymous

Hi, here below is the rule that should do this for you. It'll write these iProperties to the first found model document.

 

' Get the active document and check if it's a drawing
Dim oDoc As Document = ThisApplication.ActiveDocument
If Not oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub

' Get the first model document
Dim oModel As Document = oDoc.ActiveSheet.DrawingViews.Item(1).ReferencedFile
Dim oPropsets As PropertySets = oModel.PropertySets
Dim oPropSet As PropertySet = oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

' Pass the iProperties
Dim iProOne As String = "PF_DRWNO"
Dim iProTwo As String = "PF_DOC_REV"
Try oPropSet.Item(iProOne).Expression = iProperties.Value("Custom", iProOne) Catch oPropSet.Add("", iProOne) oPropSet.Item(iProOne).Expression = iProperties.Value("Custom", iProOne) End Try Try oPropSet.Item(iProTwo).Expression = iProperties.Value("Custom", iProTwo) Catch oPropSet.Add("", iProTwo) oPropSet.Item(iProTwo).Expression = iProperties.Value("Custom", iProTwo) End Try

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 5 of 8
Anonymous
in reply to: Owner2229

Sorry, ich habe diese Fehlermeldung, wenn die Regel in der Zeichnung gestartet wird:

 

Regelkompilierungsfehler in DocId Zeichnung nach Modell, in 325139_Türblech_513254.idw

Fehler in Zeile 6 : "end of"-Anweisung erwartet.

Fehler in Zeile 7 : "oModel" ist nicht deklariert. Auf das Objekt kann aufgrund der Schutzstufe möglicherweise nicht zugegriffen werden.

 

Message 6 of 8
Owner2229
in reply to: Anonymous

 

Try it now:

 

' Get the active document and check if it's a drawing
Dim oDoc As Document = ThisApplication.ActiveDocument
If Not oDoc.DocumentType = DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub

' Get the first model document
Dim oModel As Document = oDoc.ReferencedDocuments.Item(1)
Dim oPropsets As PropertySets = oModel.PropertySets
Dim oPropSet As PropertySet = oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

' Pass the iProperties
Dim iProOne As String = "PF_DRWNO"
Dim iProTwo As String = "PF_DOC_REV"
Try oPropSet.Item(iProOne).Expression = iProperties.Value("Custom", iProOne) Catch oPropSet.Add("", iProOne) oPropSet.Item(iProOne).Expression = iProperties.Value("Custom", iProOne) End Try Try oPropSet.Item(iProTwo).Expression = iProperties.Value("Custom", iProTwo) Catch oPropSet.Add("", iProTwo) oPropSet.Item(iProTwo).Expression = iProperties.Value("Custom", iProTwo) End Try

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 7 of 8
Anonymous
in reply to: Owner2229

Hallo,

 

die iProperties werden jetzt geschrieben, bleibven aber nicht im Modell (sie löschen sich wieder, wenn die Zeichnung geschlossen wird) 😞

 

Grüße Sascha

Message 8 of 8
Owner2229
in reply to: Anonymous

Hallo,
 
das ist, weil Sie das Modell Dokument zu speichern müssen.

 

Ich würde nicht empfehlen, so durch das Programm zu tun, da es einige Probleme verursachen können (vor allem, wenn Sie die Änderung auf das Modell nicht speichern wollen).

 

Wie auch immer, fügen Sie diese Zeile am Ende des Codes und es wird die das Modell Dokument speichern:

 

oModel.Save()

 

Übersetzt von Google Translator, tut mir so leid für alle möglichen Fehler.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods

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

Post to forums  

Autodesk Design & Make Report