Jump to content

Incorrect block insertion point


sdubbs

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...