Author Topic: Educate me please - Extrusion Direction DXF code 210  (Read 9116 times)

0 Members and 1 Guest are viewing this topic.

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« on: October 27, 2004, 03:52:22 PM »
I have a block that has an X scale of something other than 1 that is inserted with a "compound" rotation angle not only is it rotated IN the XY plane, but also FROM the XY plane.  

IMAGE

Entity data is as follows:
Code: [Select]
Command: gtt
N Select Element For Association list((-1 . <Entity name: 40a7eed8>) (0 .
"INSERT") (330 . <Entity name: 40a7ecf8>) (5 . "5B") (100 . "AcDbEntity") (67 .
0) (410 . "Model") (8 . "0") (100 . "AcDbBlockReference") (2 . "W8X31-C") (10
-0.436124 -4.47634 4.47634) (41 . 1.0) (42 . 1.0) (43 . 36.0) (50 . 0.0) (70 .
0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.5 0.5 0.707107))


I want to move the block a given distance (say 6") in the same direction of it's compound rotation (the green arrow in the "IMAGE" above).  Now I think I can hack up enough stuff using DXF 210, to do what I want, but I'm just wondering if there isn't a much better way using some VLA function or other.  Throw an old dog a bone, and I'll appreciate the help.

David Bethel

  • Swamp Rat
  • Posts: 656
Educate me please - Extrusion Direction DXF code 210
« Reply #1 on: October 27, 2004, 04:07:18 PM »
A couple rugular ( reads David doesn't use VL ) ways I can think of;

Code: [Select]
(command "_.UCS" "_E" ename)
(command "_.MOVE" ename "" '(0 0) (list 0 6))
;;;It looks like a Y axis is where you want to go
(command "_.UCS" "_P")


Or you could use a combination of (trans) and (polar) and then (entmod) the insertion point.

-David
R12 Dos - A2K

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #2 on: October 27, 2004, 04:26:27 PM »
Quote from: David D Bethel
A couple rugular ( reads David doesn't use VL ) ways I can think of;

Code: [Select]
(command "_.UCS" "_E" ename)
(command "_.MOVE" ename "" '(0 0) (list 0 6))
;;;It looks like a Y axis is where you want to go
(command "_.UCS" "_P")


Or you could use a combination of (trans) and (polar) and then (entmod) the insertion point.

-David
I planned on using ENTMOD, I avoid diddling with the UCS if I can help it.  I don't think POLAR is gonna help, doesn't it return just the angle in the XY plane?

When you first look at the extrusion vector in the entity codes it does look like a translation in the Y axis, but it is really the Z axis of the block.  That's where I need the pickaxe to hack through what's going on.  I was kinda hoping for a VLA-THINGAMABOB to just spit it out for me.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Educate me please - Extrusion Direction DXF code 210
« Reply #3 on: October 27, 2004, 04:47:35 PM »
If you are going to use ENTMOD, why not grab the block reference insertion point (it is in WCS), use the TRANS function, converting it to the current UCS, calculate POLAR from that point, then TRANS that point back to the WCS and update the object...at least I think that is the way it should work
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #4 on: October 27, 2004, 04:58:01 PM »
Given a base point for movement pt, a direction vector dir and a moving distance dist, try this little snippet to get a target point for movement:

Code: [Select]
(defun offPoint (pt dir dist)
  (mapcar (function (lambda (a b) (+ (* dist a) (* dist b)))) pt dir)
)

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #5 on: October 27, 2004, 04:59:37 PM »
Quote from: Keith
If you are going to use ENTMOD, why not grab the block reference insertion point (it is in WCS), use the TRANS function, converting it to the current UCS, calculate POLAR from that point, then TRANS that point back to the WCS and update the object...at least I think that is the way it should work
But then I'd have to diddle with the UCS in the function, right?

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #6 on: October 27, 2004, 05:01:59 PM »
Quote from: SMadsen
Given a base point for movement pt, a direction vector dir and a moving distance dist, try this little snippet to get a target point for movement:

Code: [Select]
(defun offPoint (pt dir dist)
  (mapcar (function (lambda (a b) (+ (* dist a) (* dist b)))) pt dir)
)
hmmm... the "dir" is a translation in X,Y AND Z from WORLD ucs, right?

SMadsen

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #7 on: October 27, 2004, 05:17:36 PM »
In your case it would be the direction vector, (cdr (assoc 210 elist)) - elist being the INSERT entity list you posted.
pt would be the point you want to move from and dist would be 6"

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Educate me please - Extrusion Direction DXF code 210
« Reply #8 on: October 27, 2004, 06:31:27 PM »
Quote from: CADaver
Quote from: Keith
If you are going to use ENTMOD, why not grab the block reference insertion point (it is in WCS), use the TRANS function, converting it to the current UCS, calculate POLAR from that point, then TRANS that point back to the WCS and update the object...at least I think that is the way it should work
But then I'd have to diddle with the UCS in the function, right?


Nope ... you would not have to "diddle" with the UCS ... you should be able to trans the point to the object UCS using
(trans pt 0 ob_name)

and go from there....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #9 on: October 27, 2004, 06:58:13 PM »
Quote from: SMadsen
In your case it would be the direction vector, (cdr (assoc 210 elist)) - elist being the INSERT entity list you posted.
pt would be the point you want to move from and dist would be 6"
Okay, that one hurt... what does an aneurism feel like?  I think I got it,  must   go    play,      post      back         la t  e   r  . . . . .

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #10 on: October 27, 2004, 07:00:39 PM »
Quote from: Keith
Quote from: CADaver
Quote from: Keith
If you are going to use ENTMOD, why not grab the block reference insertion point (it is in WCS), use the TRANS function, converting it to the current UCS, calculate POLAR from that point, then TRANS that point back to the WCS and update the object...at least I think that is the way it should work
But then I'd have to diddle with the UCS in the function, right?


Nope ... you would not have to "diddle" with the UCS ... you should be able to trans the point to the object UCS using
(trans pt 0 ob_name)

and go from there....
ummmm.... current UCS is WORLD, how do I get (POLAR to work in the object's ucs?

there's blood leakin' from my left ear.......

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Educate me please - Extrusion Direction DXF code 210
« Reply #11 on: October 27, 2004, 08:51:55 PM »
Hmmmm.....I think you have made me blow a gasket now ... transforming matricies from vector coordinates to angular directions for use in polar calculations ... I'll have to cogitate on this for a bit ...... I recreated your block and I must say that I have not been successful without already knowing the point location....

I was able to tranform the known point to the OCS and entmod it to the correct position, BUT as you state ... How to use polar in an extrusion direction....

I like a challenge ...
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Educate me please - Extrusion Direction DXF code 210
« Reply #12 on: October 27, 2004, 09:08:58 PM »
Why can't you use the MOVE command with the transformed points?
You would not have to mess with the UCS if you use transform, right?
Has it got to be entmod?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #13 on: October 27, 2004, 09:52:59 PM »
Quote from: CAB
Why can't you use the MOVE command with the transformed points?
You would not have to mess with the UCS if you use transform, right?
Has it got to be entmod?
No it doesn't, but I've been brain-washed (well skull-rinsed anyway) into avoiding (COMMAND.  

Considering my left pupil is fixed and blown, I am quite open to it at this point on a Wednesday night.

I almost thought I almost had it close with Stig's "OFFPOINT" function, but I've screwed it up somewhere.  Not sure enough grey matter remains oxygenated for me to understand it.

Well the ambulance has finally arrived, I'll try again tomorrow.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Educate me please - Extrusion Direction DXF code 210
« Reply #14 on: October 27, 2004, 10:20:00 PM »
CAB, the whole problem is not so much creating the point in the correct UCS, you can easily transform a point from UCS to OCS with trans,  the problem comes in when trying to determine effectively the angle at which you need to polar the point to....to get the point to transform.....

You want to move from pt1 to pt2 ...pt1 is known as the insertion point of obj, pt2 must be obtained from an offset of 6 in a direction vector of an unknown UCS system. The real problem is determining the angle at which the object is from the WCS XY plane.

Essentially what angle (as required by polar) would you use if all you know is the direction vector of (0.5 0.5 0.707107) ....
that is the real problem....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #15 on: October 28, 2004, 06:40:52 AM »
Here's another attempt. Not sure what direction you are looking to move the insert but this moves it along the direction vector.
It should do the whole shebang with selection and distance input but no error checking to see if input is valid.

Code: [Select]
(defun C:MOVEINS ()
  ;; get an insert (no error checking!)
  ;; get a displacement distance
  (setq blk (entsel "\nSelect block: ")
        len (getdist "\nDistance to move: ")
  )
  ;; get entity list and extract
  ;; insertion point and direction vector
  (setq blkl (entget (car blk))
        ins  (cdr (assoc 10 blkl))
        dir  (cdr (assoc 210 blkl))
  )
  ;; calculate actual insertion point and
  ;; move it len units along the direction vector
  (setq realins (trans ins dir 1)
        newpt   (mapcar '+ realins (mapcar '(lambda (n) (* n len)) dir))
  )
  ;; transform newpt back to insertion point
  ;; and update block
  (entmod (subst (cons 10 (trans newpt 1 dir))(assoc 10 blkl) blkl))
)

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #16 on: October 28, 2004, 08:24:57 AM »
HAPPY HAPPY JOY JOY HAPPY HAPPY JOY JOY

That's it, thanks Stig, works a champ.  Now, I just gotta bend it into the rest of my little function.

Not gonna tell where I screwed up the Lambda function last night.  That's what I get for trying to write code on the back end of a 16hr day.

Thanks for all the help guys.

Oh, yeah, brain damage was minimal, but then it had no choice.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Educate me please - Extrusion Direction DXF code 210
« Reply #17 on: October 28, 2004, 08:30:00 AM »
Stig
your routine moved my test block but not along the long axis.
perhaps I did not create my block correctly, but would it not be
better to pick two points on the block to establish the direction
for the block to be moved? I know that is not what CADaver ask for.
I am just kicking this around so I can understand it.

Thanks
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Educate me please - Extrusion Direction DXF code 210
« Reply #18 on: October 28, 2004, 08:33:17 AM »
OK CADaver jumped in there and it looks like you solved his problem.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

whdjr

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #19 on: October 28, 2004, 08:36:04 AM »
Just another thought:
I could see this very useful in this routine that I was writing.  Could it be modified to work with polyline points or is this strictly for blocks?

SMadsen

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #20 on: October 28, 2004, 08:47:46 AM »
Will, this was strictly for blocks .. given that it transforms insertion points .. but you can use TRANS to transform any points for whichever kind of entity. Just keep in mind that lightweight plines have the Z value placed in an elevation and not within the vertices.

CAB, I took a stab at moving the block along the direction vector, not knowing if this was the direction CADaver wanted because it wasn't specified how the block was defined. You could define whichever direction to move it by rotating the direction vector accordingly

CADaver

  • Guest
Educate me please - Extrusion Direction DXF code 210
« Reply #21 on: October 28, 2004, 08:51:34 AM »
Quote from: CAB
Stig
your routine moved my test block but not along the long axis.
perhaps I did not create my block correctly,
Thanks


The block I'm using is a "column" with X and Y scales of 1 and a Z scale of the "column" height, insertion point at the bottom.  When used as a "brace" we just rotate it away from vertical, then "spin" it where it needs to point.

I have a routine that builds it originally along a previously drawn centerline, but you guys know just how quick something can change.  What we've been doing when stuff changes is just delete the old and build new, I was lookin' for a way to just modify what's there.  Reaching in and changing the Z scale with entmod was pretty easy, but moving the "brace" along it's Z axis made me stutter.

I think I may have it now, if I really understand what I think I see happening in Stig's routine.

Again, thanks guys.