MJLM Posted April 28, 2020 Share Posted April 28, 2020 In continuation of this thread I would like to continue this interesting story about UCSs and transformed entities. So far I have understood ( I am thankful to the community here) that An OCS is an coordinate system that most of the Autocad entities use instead of any other CS An OCS share the same origin with the WCS, however its x,y,z may be other than the one of the WCS However, it seems that something still eludes me and I cannot fully grasp it. I made a very simple model with a line drawn in WCS from 0,0,0 to 1,2,3. I would like to insert the same model on this one, that is having this line sitting on the end point (1,2,3) of the other as an extension. That means the lines need to be collinear. Let's assume I mirror3d this line on the xy plane, so the extrusion vector now becomes 0.0 0.0 -1.0. Using the following snippet the line comes on the correct placement but the orientation is wrong. What am I missing? ; clicking the mirrored entity from 0,0,0 to 1,2,-3 (setq pt (cdr (assoc 11 (setq ent (entget (car (entsel))))))) (setq v (cdr (assoc 210 ent))) ; inserting the drawing (entmakex (list (cons 0 "INSERT") (cons 2 "Dwg") (cons 8 "0") (cons 10 (trans (trans pt 0 1) 1 v)) (cons 70 0) (cons 66 1) (cons 50 0) (cons 210 v) ) ) Any suggestions appreciated. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 28, 2020 Share Posted April 28, 2020 Lines are not planar entities, and therefore their endpoints are defined relative to the WCS and they do not uniquely define a plane, as such, the associated extrusion vector will be essentially arbitrary, and dependent upon the active UCS when the line was created. Quote Link to comment Share on other sites More sharing options...
MJLM Posted April 28, 2020 Author Share Posted April 28, 2020 That only complicates things. I was under the impression that one inserted block could be placed per the state of an other object in the master drawing (location & orientation). On the other thread I posted above that worked. I just don't understand what's the difference. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 28, 2020 Share Posted April 28, 2020 2 hours ago, MJLM said: That only complicates things. I was under the impression that one inserted block could be placed per the state of an other object in the master drawing (location & orientation). On the other thread I posted above that worked. I just don't understand what's the difference. It depends what the "other object" is - if such object is planar (e.g. arc, circle, 2D polyline, block reference etc.), then the block can be inserted to reside in the same plane as the existing object, however as noted above, a line on its own does not define a unique plane (observe that any plane can be rotated about the line) and so the plane in which the new block reference should reside is ambiguous. Quote Link to comment Share on other sites More sharing options...
MJLM Posted April 28, 2020 Author Share Posted April 28, 2020 I guess I'm just looking for that one plane passing through the insertion point and being perpendicular to the transformed line (ie normal vector). I m investigating. I will come back on this. Quote Link to comment Share on other sites More sharing options...
MJLM Posted May 4, 2020 Author Share Posted May 4, 2020 When inserting a block with (command-s "_.insert" path "_non" inspt 1.0 1.0 0.0) and trying to orient it with (entmod (subst nrv (assoc 210 ins_ent) ins_ent)) where nrv is the desired normal vector in form of (cons 210 '(i j k)) produces a wrong placement. When trying to translate it back to the correct location using (entmod (subst (trans inspt (cdr nrv) 1) (assoc 10 (entget (entlast))) (entget (entlast))) it simply does not work. What am I missing here? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted May 4, 2020 Share Posted May 4, 2020 Since the insertion point is expressed relative to the OCS defined by the normal vector, you'll need to transform the insertion point to the OCS defined by the new normal, e.g.: (entmod (subst (cons 10 (trans (cdr (assoc 10 ins_ent)) (cdr (assoc 210 ins_ent)) (cdr nrv))) (assoc 10 ins_ent) (subst nrv (assoc 210 ins_ent) ins_ent) ) ) Quote Link to comment Share on other sites More sharing options...
MJLM Posted May 4, 2020 Author Share Posted May 4, 2020 Thank you Lee. You saved me once again. 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.