{"id":3875,"date":"2019-06-05T00:49:42","date_gmt":"2019-06-05T07:49:42","guid":{"rendered":"https:\/\/blogs.plm.automation.siemens.com\/t5\/Solid-Edge-Blog\/Conversions-and-Transformations-using-the-Solid-Edge-API-Part-3\/ba-p\/594317"},"modified":"2020-02-17T09:42:31","modified_gmt":"2020-02-17T14:42:31","slug":"conversions-and-transformations-using-the-solid-edge-api-part-3","status":"publish","type":"post","link":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/conversions-and-transformations-using-the-solid-edge-api-part-3\/","title":{"rendered":"Conversions and Transformations using the Solid Edge API &#8211; Part 3"},"content":{"rendered":"<p><P><a href=\"https:\/\/community.plm.automation.siemens.com\/t5\/Solid-Edge-Blog\/Conversions-and-Transformations-using-the-Solid-Edge-API-Part-2\/ba-p\/594103\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">&#8230;continued from part 2<\/A><\/P><\/p>\n<p><P>This series of articles discusses the following:<\/P><\/p>\n<p><OL><br \/>\n<LI><U>Document Unit Conversion<\/U><SPAN>&nbsp;<\/SPAN>&#8211; ParseUnit and Format Unit methods of the UnitsOfMeasure object.<\/LI><br \/>\n<LI><U>View Coordinate Conversion<\/U><SPAN>&nbsp;<\/SPAN>&#8211; ViewToSheetViewToSheetViewToSheetViewToSheetViewToSheet and SheetToView methods of the DrawingView object.<\/LI><br \/>\n<LI><U>2D to 3D Conversion<\/U><SPAN>&nbsp;<\/SPAN>&#8211; Convert2DCoordinate method of the Profile object.<\/LI><br \/>\n<LI><U>3D to 2D Transformations<\/U><SPAN>&nbsp;<\/SPAN>&#8211; ModelToView method of the DrawingView object.<\/LI><br \/>\n<LI><U>Assembly Transformations<\/U><SPAN>&nbsp;<\/SPAN>&#8211; GetMatrix and PutMatrix methods of the Occurrence object.<\/LI><br \/>\n<\/OL><\/p>\n<p><P><STRONG>Model to Drawing View Conversion<\/STRONG><\/P><\/p>\n<p><P>This part of the conversion and transformation series discusses a case where a hole exists in the part model and its center point in the drawing views need to be found in terms of the sheet or document units.<\/P><\/p>\n<p><P>The case is illustrated in this image:<\/P><\/p>\n<p><P><span class=\"lia-inline-image-display-wrapper lia-image-align-center\" style=\"width: 383px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/CAT071-1.png\" alt=\"CAT071.png\" title=\"CAT071.png\" \/><\/span><\/P><\/p>\n<p><P>The hole is created in the ordered mode and has a profile which can be accessed as below:<\/P><\/p>\n<p><PRE>Dim seApp As SolidEdgeFramework.Application =<br \/>\nSystem.Runtime.InteropServices.Marshal.GetActiveObject(&#8220;Solidedge.Application&#8221;)<\/p>\n<p>Dim sePartDoc As SolidEdgePart.PartDocument = seApp.ActiveDocument<br \/>\nDim seHole As SolidEdgePart.Hole = sePartDoc.Models.Item(1).Holes.Item(1)<br \/>\nDim seHoleProfile As SolidEdgePart.Profile = seHole.Profile<\/PRE><\/p>\n<p><P>The center point of the profile is a 2d point since a profile is essentially in a 2d plane:<\/P><\/p>\n<p><PRE>Dim xHole As Double, yHole As Double<br \/>\nseHoleProfile.Holes2d.Item(1).GetCenterPoint(xHole, yHole)<br \/>\n<\/PRE><br \/>\n<P>The center point needs to be converted to a 3d point since the hole is in 3D space on the model.<\/P><br \/>\n<P>Here comes our first conversion:<\/P><\/p>\n<p><PRE>Dim xHole3D As Double, yHole3D As Double, zHole3D As Double<br \/>\nseHoleProfile.Convert2DCoordinate(xHole, yHole, xHole3D, yHole3D, zHole3D)<br \/>\n<\/PRE><br \/>\n<P>This gives the hole\u2019s center point in 3D space as illustrated in the image above.<\/P><\/p>\n<p><P>The target is to locate the same point on a sheet where the drawing views of the model are placed as shown below:<\/P><\/p>\n<p><P><span class=\"lia-inline-image-display-wrapper lia-image-align-center\" style=\"width: 437px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/CAT081-1.png\" alt=\"CAT081.png\" title=\"CAT081.png\" \/><\/span><\/P><\/p>\n<p><P>This calls for the second conversion from model to view and happens in the Draft document:<\/P><\/p>\n<p><PRE>Dim seDraftDoc As SolidEdgeDraft.DraftDocument = seApp.ActiveDocument<br \/>\nDim seSheet As SolidEdgeDraft.Sheet = seDraftDoc.ActiveSheet<\/p>\n<p>Dim seView As DrawingView = seSheet.DrawingViews.Item(1)<br \/>\nDim xView As Double, yView As Double, xSheet As Double, ySheet As Double<br \/>\nseView.ModelToView(xHole3D, yHole3D, zHole3D, xView, yView)<\/PRE><br \/>\n<P>This converts the 3d coordinate to the 2d equivalent in the draft\u2019s view but not yet on the sheet in terms of the draft document\u2019s units.<\/P><\/p>\n<p><P>This is done in the 3rd conversion where the view coordinates are converted to sheet coordinates as explained in the previous episode of this series.<\/P><\/p>\n<p><PRE>seView.ViewToSheet(xView, yView, xSheet, ySheet)<\/PRE><\/p>\n<p><P>This completes the conversion of a hole\u2019s center point from the 3D model to the 2D sheet.<\/P><\/p>\n<p><P>The next part will show how to perform matrix manipulations on occurrences to move and rotate them in the assembly environment.<\/P><\/p>\n<p><P>If you have any questions, please use the <a href=\"http:\/\/community.plm.automation.siemens.com\/t5\/Solid-Edge-Developer-Forum\/bd-p\/SEDeveloperForum\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">Solid Edge Developer forum<\/A> to post messages.<\/P><\/p>\n<p><P><SPAN>Tushar Suradkar<\/SPAN><\/P><br \/>\n<P><SPAN><a href=\"http:\/\/www.cadvertex.com\/\" target=\"_blank\" rel=\"noopener nofollow noreferrer\">www.CADVertex.com<\/A><\/SPAN><\/P><br \/>\n<P><a href=\"http:\/\/www.surfandcode.in\/2014\/01\/index-of-all-tutorials-on-this-solid.html\" target=\"_blank\" rel=\"noopener nofollow noreferrer\"><SPAN>www.SurfAndCode.IN<\/SPAN><\/A><\/P><\/p>\n<p><P>Join the Solid Edge User Group on FaceBook:<\/P><br \/>\n<P><a href=\"https:\/\/www.facebook.com\/groups\/solidedgeusers\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https:\/\/www.facebook.com\/groups\/solidedgeusers\/<\/A><\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8230;continued from part 2 <\/p>\n<p> This series of articles discusses the following: <\/p>\n<p> Document Unit Conversion &#8211; ParseUnit and Format Unit methods of the UnitsOfMeasure object.<br \/>\n V&#8230;<\/p>\n","protected":false},"author":42979,"featured_media":3882,"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-3875","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\/CAT081-1.png","_links":{"self":[{"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/3875","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=3875"}],"version-history":[{"count":3,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/3875\/revisions"}],"predecessor-version":[{"id":3883,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/3875\/revisions\/3883"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/media\/3882"}],"wp:attachment":[{"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/media?parent=3875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/categories?post=3875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/tags?post=3875"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/industry?post=3875"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/product?post=3875"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blogs.stage.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/coauthors?post=3875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}