sdubbs Posted August 26, 2010 Share Posted August 26, 2010 Hi, I have some code that gets the insertion point of a block to ensure that it is inserted at 0,0,0. When I list the block in Autocad, the insertion point is 0,0,0 (even when units are set to 8 decimal points). When I get the insertion point for the block in vba it shows insertionpoint(0) = -2.05182e-009. Why would the insertion point not be the same value as what was shown in autocad? Quote Link to comment Share on other sites More sharing options...
Dana W Posted August 26, 2010 Share Posted August 26, 2010 Check the block (editor) to see if there is a hard insertion point included there. Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 26, 2010 Share Posted August 26, 2010 The coordinate returned is for UCS or WCS? Quote Link to comment Share on other sites More sharing options...
sdubbs Posted August 26, 2010 Author Share Posted August 26, 2010 UCS is set to world and the block has an insertion point of 0,0,0. Quote Link to comment Share on other sites More sharing options...
Dana W Posted August 26, 2010 Share Posted August 26, 2010 Is this a title block/borderline in paperspace? If so the offset may have something to do with the plot offset. Has someone manipulated this off of 0,0? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 26, 2010 Share Posted August 26, 2010 Post your code, and block, please. Quote Link to comment Share on other sites More sharing options...
sdubbs Posted August 26, 2010 Author Share Posted August 26, 2010 I have attached the block. When I check the xdata of the block I can see the incorrect insertion point (10 -2.05182e-009 0.0 0.0). When I list the block the insertion point is 0,0,0. Here is the code that checks the block to ensure it's inserted at 0,0,0: Private Sub checkTitleBlockInsertionPoint() Dim temp1 As AcadBlockReference If strDrawingType = "iso" Then grpCode(0) = 2 dataVal(0) = strIsoBorderBlockName Else grpCode(0) = 2 dataVal(0) = strGABorderBlockName End If 'Problem found with iso border insertion point not reading properly. 'Temporarily remove the check for insertion point. If strDrawingType <> "iso" Then Set ssetobj = AddSelectionSet("SS01") mode = acSelectionSetAll ssetobj.Select mode, , , grpCode, dataVal Set temp1 = ssetobj.Item(i) i = 0 For i = 0 To 2 If temp1.InsertionPoint(i) <> 0 Then errorType (2) Exit For End If i = i + 1 Next End If End Sub Quote Link to comment Share on other sites More sharing options...
BlackBox Posted August 26, 2010 Share Posted August 26, 2010 I mostly program using Visual LISP (ActiveX) so forgive my need for clarification... In the VBAIDE, under Object Browser, the InsertionPoint property is a variant that should return (x y z), not (10 x y z) like DXF code, correct? Quote Link to comment Share on other sites More sharing options...
sdubbs Posted August 26, 2010 Author Share Posted August 26, 2010 Yes, you're correct. The insertionpoint is a variant (Insertionpnt(i) in my code). I just included the dxf group code 10 to show what is returned for the insertion point in vba. When I debug the code, the value shown for x is -2.05182e-009, when it is actually 0 when I list the block. Quote Link to comment Share on other sites More sharing options...
SEANT Posted August 26, 2010 Share Posted August 26, 2010 The notation -2.05182e-009 equates to -0.00000000205182. That would not show in a reading with only 8 decimal places. In the bigger picture, though, that value should be considered 0. See this webpage listing guidelines a programmer should consider when dealing with Decimal/Binary conversion. http://support.microsoft.com/kb/125056 Quote Link to comment Share on other sites More sharing options...
Tyke Posted August 31, 2010 Share Posted August 31, 2010 I had a similar problem when comparing line end point coordinates. The code checked to see if they were equal and everytime it said they were not equal, even though the two lines had been drawn with end point snap on. For me they were equal, but for VBA they were not. The difference was 0.000000000001 millimetres!!! I introduced a fuzzy check and regarded them as equal if the difference was less than my fuzzy tolerance. You have to determine your own tolerance. It will be different for someone designing precision tools than it would be for someone working with GNSS coordinates. Then I got the results that I expected. ' first check the eastings of the start point If Abs(dblTempStart(0) - dblNewEnd(0)) < dblFuzzy Then ' then check the northings If Abs(dblTempStart(1) - dblNewEnd(1)) < dblFuzzy Then dblTemp(0) = dblTempStart(0) dblTemp(1) = dblTempStart(1) dblTemp(2) = dblTempStart(2) dblNewEnd(0) = dblTempEnd(0) dblNewEnd(1) = dblTempEnd(1) dblNewEnd(2) = dblTempEnd(2) objFound = True End If . . . Else . . . End If Can you make use of that? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.