Jump to content

Recommended Posts

Posted

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.

Posted (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 by Jonathan Handojo
Account for angle to UCS
Posted

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.

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