{"id":4831,"date":"2014-08-03T07:25:08","date_gmt":"2014-08-03T14:25:08","guid":{"rendered":"https:\/\/blogs.plm.automation.siemens.com\/t5\/Solid-Edge-Blog\/Automation-Parametric-Assemblies\/ba-p\/264127"},"modified":"2020-02-17T09:43:31","modified_gmt":"2020-02-17T14:43:31","slug":"automation-parametric-assemblies","status":"publish","type":"post","link":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/automation-parametric-assemblies\/","title":{"rendered":"Automation: Parametric Assemblies"},"content":{"rendered":"<p><P>This article builds on the knowledge gained in the previous post <a href=\"https:\/\/blogs.plm.automation.siemens.com\/t5\/Solid-Edge-Blog\/Automation-Parametric-Parts\/ba-p\/36482\" target=\"_blank\" rel=\"noopener noreferrer\">Parametric Parts<\/A> which discussed how to parametric parts by changing the values of part variables.<\/P><\/p>\n<p><P>It is also possible to access and modify a part&#8217;s variables directly when it is already inserted into an assembly. This is similar to accessing the peer variables.<\/P><\/p>\n<p><DIV class=\"lia-message-body lia-component-body\"><br \/>\n<DIV class=\"lia-message-body-content\"><br \/>\n<P>When used interactively, the peer variable asks for an assembly component.<\/P><br \/>\n<P>Similarly you can access the OccurrenceDocument or the OccurrenceFileName first and then seek its variables.<\/P><\/p>\n<p><P>The &#8216;OccurrenceDocument&#8217; object of an occurrence in the assembly can be used to access the peer variables of the occurrence part.<\/P><\/p>\n<p><P><span class=\"lia-inline-image-display-wrapper lia-image-align-left\" style=\"width: 189px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/01-5.png\" alt=\"01.png\" title=\"01.png\" \/><\/span>Open carrier.asm from the Solid Edge STxTraining folder and from the Tools tab start Variables. Note that there are just three variables in the assembly document itself.<\/P><\/p>\n<p><P>However there are also 3 parts in the assembly and say you want to change the thickness of the SPlate.par without actually opening it.<\/P><\/p>\n<p><P><span class=\"lia-inline-image-display-wrapper lia-image-align-right\" style=\"width: 166px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/02-5.png\" alt=\"02.png\" title=\"02.png\" \/><\/span>To do this, start Peer Variables and select the Splate part from the PathFinder.<\/P><\/p>\n<p><P>The Variable Table now reflects the variable for the Splate part. Some variables are grayed out while those with the white background are the ones that can be edited.<\/P><\/p>\n<p><P>The V360 is the one for thickness of the plate.<\/P><\/p>\n<p><P>The document variable should be declared as an AssemblyDocument:<\/P><\/p>\n<p><PRE>Dim oDoc As SolidEdgeAssembly.AssemblyDocument = oApp.ActiveDocument<\/PRE><\/p>\n<p><P>Access the required part from the assembly occurrences by either using its index number:<\/P><\/p>\n<p><PRE>Dim oOccurrence As SolidEdgeAssembly.Occurrence = oDoc.Occurrences.Item(&#8220;2)<\/PRE><\/p>\n<p><P>or its placement name as below:<\/P><\/p>\n<p><PRE>Dim oOccurrence As SolidEdgeAssembly.Occurrence = oDoc.Occurrences.Item(&#8220;Splate.par:1&#8221;)<\/PRE><br \/>\n<P>You can find the placement name of the occurrence by right-clicking it and selecting <EM>Occurrence Properties<\/EM> form the context menu.<\/P><\/p>\n<p><P>Next step is to access the part document associated with the occurrence:<\/P><\/p>\n<p><PRE>Dim oOccuPart As SolidEdgePart.PartDocument = oOccurrence.OccurrenceDocument<\/PRE><\/p>\n<p><P>As you see, there is no need to actually open the part and access its variables.<\/P><br \/>\n<P>The Part document is referenced directly from the occurrence and its variables are accessed:<\/P><\/p>\n<p><PRE>Dim oVars As SolidEdgeFramework.Variables = oOccuPart.Variables<\/PRE><\/p>\n<p><P>The remaining part to change the variable is fairly similar as seen in the&nbsp;<a href=\"https:\/\/blogs.plm.automation.siemens.com\/t5\/Solid-Edge-Blog\/Automation-Parametric-Parts\/ba-p\/36482\" target=\"_blank\" rel=\"noopener noreferrer\">Parametric Parts<\/A> article:<\/P><\/p>\n<p><PRE>oVars.Edit(&#8220;V360&#8221;, &#8220;24&#8221;) &#8216; Older value = 20<br \/>\noDoc.UpdateAll()<\/PRE><\/p>\n<p><P>Finally, oDoc.UpdateAll() updates the assembly document and is equivalent to the Update All Links command <span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 32px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/03-7.png\" alt=\"03.png\" title=\"03.png\" \/><\/span><\/P><\/p>\n<p><P>&nbsp;Give this powerful feature a try by building a simple Windows Forms application.<\/P><\/p>\n<p><\/DIV><br \/>\n<\/DIV><br \/>\n<P>In case you decide to try out something different or further to what is discussed here and run into any problems or errors, do not hesitate to post a query on the <a href=\"https:\/\/blogs.plm.automation.siemens.com\/t5\/Solid-Edge-Developer-Forum\/bd-p\/SEDeveloperForum\" target=\"_blank\" rel=\"noopener noreferrer\">Solid Edge Developer forum<\/A>.<\/P><\/p>\n<p><P>Simply click the <a href=\"https:\/\/blogs.plm.automation.siemens.com\/t5\/forums\/postpage\/board-id\/SEDeveloperForum\" target=\"_blank\" rel=\"noopener noreferrer\">New Message<\/A> button found at the top of the page.<\/P><\/p>\n<p><P>~Tushar Suradkar<\/P><br \/>\n<P><a href=\"http:\/\/surfandcode.blogspot.in\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">http:\/\/surfandcode.blogspot.in<\/A><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article builds on the knowledge gained in the previous post Parametric Parts which discussed how to parametric parts by changing the values of part variables. <\/p>\n<p> It is also possible to a&#8230;<\/p>\n","protected":false},"author":42979,"featured_media":4840,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spanish_translation":"","french_translation":"","german_translation":"","italian_translation":"","polish_translation":"","japanese_translation":"","chinese_translation":"","footnotes":""},"categories":[1,96],"tags":[33],"industry":[],"product":[],"coauthors":[],"class_list":["post-4831","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","category-tips-tricks","tag-developer"],"featured_image_url":"https:\/\/blogs.stage.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/02-5.png","_links":{"self":[{"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/4831","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/users\/42979"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/comments?post=4831"}],"version-history":[{"count":4,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/4831\/revisions"}],"predecessor-version":[{"id":4842,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/4831\/revisions\/4842"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/media\/4840"}],"wp:attachment":[{"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/media?parent=4831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/categories?post=4831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/tags?post=4831"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/industry?post=4831"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/product?post=4831"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/coauthors?post=4831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}