There is an example on CodePlex which shows (using c# and the SDK) how to add a line with a dimension attacthed to each end showing the length... great. BUT, I need to add two blocks, say 2 simplete square boxes and I have to add a dimension which goes from one to the other and shows the distance between them.. ALL from code. does anyone have ANY kind of example of how to do this?
This seems pretty basic.. But I had actual contact with a developer FROM Siemens and they couldn't understand what I was trying to do. Essentially I am trying to add a "Smart Dimension" between two objects, completely from code.
// Declare Dimensions collection Dimensions dimensions = null; Dimension dimension = null; // (...) dimension = (Dimension)dimensions.AddDistanceBetweenObjects( Object1: x1: x2: z1: keyPoint1: Object2: x2: y2: z2: keyPoint2: );
Thanks for the response. I've tried that method a number of times with no luck. My current interation is throwing the exception:
System.InvalidCastException: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)) at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32 aWrapperTypes, MessageData& msgData) at SolidEdgeFrameworkSupport.Dimensions.AddDistanceBetweenObjects(Object Object1, Double x1, Double y1, Double z1, Boolean keyPoint1, Object Object2, Double x2, Double y2, Double z2, Boolean keyPoint2) at SolidEdgeConsoleTest.Program.Main(String args) in C:\Development\SolidEdge Development\SolidEdgeConsoleTest\SolidEdgeConsoleTest\Program.cs:line 65
Here's my code. I'm using BlockOrrcurance objects from the active sheet..
SED.Blocks blocks = seDraft.Blocks; SED.Block b1 = CreateDraftBlock(blocks, "B1", heightWidth); // this method builds the 4 lines of the BO SED.Block b2 = CreateDraftBlock(blocks, "B2", heightWidth);
seApp.Interactive = true;
seApp.Activate(); SED.Sheet sheet = seDraft.ActiveSheet; SED.BlockOccurrence bo1 = sheet.BlockOccurrences.Add(b1.Name, b1loc.Horizontal, b1loc.Vertical); SED.BlockOccurrence bo2 = sheet.BlockOccurrences.Add(b2.Name, b2loc.Horizontal, b2loc.Vertical); double x1, y1, x2, y2; bo1.GetOrigin(out x1, out y1); bo2.GetOrigin(out x2, out y2); SEFS.Dimensions dimensions =(SEFS.Dimensions)sheet.Dimensions; SEFS.Dimension dimension = null; dimension = (SEFS.Dimension)dimensions .AddDistanceBetweenObjects( Object1: bo1, x1: x1, y1: y1, z1: 0.0, keyPoint1: false, Object2: bo2, x2: x2, y2: y2, z2: 0.0, keyPoint2: false);
Everything up to the AddDistance method workd. both blocks get drawn on the drawing fine..