MJLM Posted April 27, 2020 Posted April 27, 2020 I am trying to insert a block using the entmake method. The block must be inserted on a specific point as well as with a specific orientation, meaning that the block must be rotated in 3D space for correct placement. I have the UCS (or WCS) point to insert it, I have the normal vector (e.g. 210 dxf code) that needs to be oriented but for some strange reason I can only either correctly place it or orient it, not both. This is the short code I am using (entmakex (list (cons 0 "INSERT") (cons 2 "S1") (cons 8 "0") (cons 10 pt) (cons 70 0) (cons 66 1) (cons 50 0) (cons 210 v) ) ) (entmakex '((0 . "SEQEND"))) The pt is expressed in the currect UCS (or WCS) and v is the normal vector (in this case it happens to be '(0.347329 0.14033 0.927184). The block is a dwg file saved in library with a normal vector of '(0.0 0.0 1.0). Any suggestions appreciated. Quote
Jonathan Handojo Posted April 27, 2020 Posted April 27, 2020 (edited) This is assuming that you are drawing in plane with the UCS, thus the extrusion vector (normal) is the Z-vector of the UCS: (defun c:tst ( / nrm) (setq nrm (trans '(0.0 0.0 1.0) 1 0 T)) (entmake (list '(0 . "INSERT") '(100 . "AcDbEntity") '(100 . "AcDbBlockReference") (cons 2 block_name) (cons 10 (trans pt_in_ucs 1 nrm)) (cons 50 (+ (angle '(0 0 0) (trans (getvar 'ucsxdir) 0 nrm T)) rotation)) (cons 210 nrm) ) ) ) Edited April 27, 2020 by Jonathan Handojo Account for angle to UCS Quote
Lee Mac Posted April 27, 2020 Posted April 27, 2020 Also answered here: https://www.theswamp.org/index.php?topic=55985.new#new Quote
Jonathan Handojo Posted April 27, 2020 Posted April 27, 2020 8 minutes ago, Lee Mac said: Also answered here: https://www.theswamp.org/index.php?topic=55985.new#new I just realised that the angle would also be affected if not translated. Quote
MJLM Posted April 27, 2020 Author Posted April 27, 2020 Thank you for the support. It works now. I tried to reply my thanks to the swamp as well but it seems I wont be posting anytime soon. I cannot understand why do I need to answer silly questions about people & companies I do not know every time. Quote
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.