Jump to content

Move Command End Position Error (Assumed Precision/Floating Point Error)


Recommended Posts

Posted

Hello,

 

I am trying to create a lisp function for batch processing that moves,scales creates a bounding rectangle for polylines that were generated from another batch process that created them from isolated png objects that are of a random scale. The end goal will be for creating camera facing faces in Sketchup that use these polylines as boundaries for correct shadows.

 

Here is my current code (probably not the most optimized approach yet) and a sample file that demonstrates the issue.

[ATTACH]60822[/ATTACH][ATTACH]60823[/ATTACH]

 

The issue is that the move command in the function is supposed to move all the polylines from the bottom center of the bounding box to origin however if the bounding box that gets created is already close to the origin it doesn't end up moving to the origin but keeps the original close values. It works perfectly if you move the polylines away from the origin first. This becomes a problem when it is scaled after which uses the origin as a base point, amplifying the distance away from the origin and scaling it incorrectly.

 

I could probably workaround this by changing the order of operations or adding an extra move command to move it away if it is near the origin initially but I was wondering if there is a proper fix for this issue.

 

Side note: If someone one knows of a lisp function that can replicate

or can roughly explain the method they are using to determine when a segment(arc or line) starts or ends so I can attempt it myself it would be appreciated. They mention fuzzy logic but have not looked into it fully. I can already prune out redundant vertices by comparing centers of bulges for arcs and co-linear test(ab+ac=ac) for lines. Thanks.
Posted

Your attachments are not valid. But the issue you describe sounds a lot like the classic 'Running Osnaps Problem'.

 

3 solutions:

1. Set the OSMODE variable to 0 before using the _Move command.

2. Use "_non" to override the OSMODE setting.

3. Use vla-move instead of the _Move command.

 

Example of solution 2:

(command "_.move" ss "" "_non" pt1 "_non" pt2)

Posted

Thanks, looks like that was the issue as those solutions work. Here is a second attempt at uploading the original attachments for those interested: Scale2HumanSize.lsp

 

It looks like I still need to add all the polyline vertices to the point list as well though, as the vla-getboundingbox seems to miss some points and is current view dependent.

Sample Drawing that Causes Error.dwg

Posted

Your last statements are incorrect. The vla-getboundingbox function does not miss points (it calculates two: a 'min' and 'max' point) and is not dependent on the current view.

Posted

That could be I am still a beginner at lisp coding. It was probably on the draw rectangle command with osnaps running that was making it look incorrect then. Adding your first solution instead of your second solution just to the move command fixed it in all cases so far.

 

Are there any other system variables that I should watch out for with lisp programs? (or a forum/website that lists them)

 

Thanks again for the help.

 

Here is the working version: Scale2HumanSize.lsp.

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...