Jump to content

Recommended Posts

Posted

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?

 

image.thumb.png.a8d3b3d9d970691f9a1f8efb084064b4.png

 

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

 

 

Posted

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.

Posted

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.

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

Posted

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.

Posted

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?

Posted

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

 

Posted

Thank you Lee. You saved me once again.

 

 

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