Hi Guys,
how can i get/set the entity ucs, the (entget) only returns 210 as extrusion direction but that's doesn't tell us the XY direction
if the ucs only rotate about the Z axis
i writing a command to copy (using COPY command) some texts from one ucs to current ucs and i would like the copied text to align to the current ucs
Thanks in Advance
Moshe
Solved! Go to Solution.
Solved by Kent1Cooper. Go to Solution.
Solved by Moshe-A. Go to Solution.
got it, as long as the ucs is rotate about Z axis only, there is no difference in extrusion direction so it is the same as wcs
thank you
@Moshe-A wrote:
....
how can i get/set the entity ucs, the (entget) only returns 210 as extrusion direction but that's doesn't tell us the XY direction if the ucs only rotate about the Z axis
....
Once you've set the UCS to match an object, look into the values of the UCSXDIR and UCSYDIR System Variables. Whether you can find out what they would be before changing the UCS to match, by selecting the object, probably depends on the object type.
The X & Y directions are determined by applying the Arbitrary Axis Algorithm to the extrusion vector (normal vector); this algorithm is implemented in the AutoLISP trans function, which also accepts a normal vector argument.
Lee
Lee,
The command i'm writting is restricted to work only on UCS that are rotated about Z axis.
i checked some objects in numerous UCS rotated about Z and all produced the same extrusion direction of (210 0.0 0.0 1.0)
how (trans) function would give me the right UCS XY direction?
could you give me an example?
thanks, Moshe
Hi Kent,
OK...let say i take your approch and for each text set it's UCS to current and check it's ucsXdir & ucsYdir
copy the text to a new location and get it's database list
(setq elist (entget (entlast)))
Now how can i set the object ucs in elist?
maybe instead of using COPY command to set the origin text UCS
and create the copied text with (entmake) would it align with the current UCS?
thanks, Moshe
The command i'm writting is restricted to work only on UCS that are rotated about Z axis.
i checked some objects in numerous UCS rotated about Z and all produced the same extrusion direction of (210 0.0 0.0 1.0)
how (trans) function would give me the right UCS XY direction?
could you give me an example?
Hi Moshe-A,
I think there is some confusion -
Planar objects (such as 2D polylines, circles, arcs etc.) define their own coordinate system known as the Object Coordinate System (OCS), whose axis vectors are calculated by applying the Arbitrary Axis Algorithm to the extrusion vector of the entity (i.e. the normal vector of the plane in which it resides). The origin of the OCS coincides with the WCS origin, and the direction of the OCS axis vectors will be unaffected by rotation of the active UCS.
Note that the OCS of an entity is always calculated from the extrusion vector of the entity using the method described above, and hence does not depend on the rotation or orientation of the active UCS, which is completely independent of an object.
To obtain the X & Y directions of the active UCS, you would need to retrieve the value of the UCSXDIR & UCSYDIR System variables, as Kent has suggested above; however, note that these are entirely independent of any objects and are only affected by the orientation of the active UCS.
Lee
Lee,
what i meant is i want to know what was the XY direction of the ucs at the time the texts were drawn and i now understand that there is no such thing - am i right?
i have decided to take another approch here, instead copying each text at a time i will gather all selected objects in anonymous block and insert it align to the current ucs (and i do not mind what was the the XY direction at the time)
by the way about (entmake) & (entmakex) what is the difference between them?
i'm facing difficulties in appending a blockref with attributes to anonymous blockdef, dxf code 66 is not allowed,
have you got a workround this?
thanks,
Moshe
@Moshe-A wrote:
Hi Kent,
OK...let say i take your approch and for each text set it's UCS to current and check it's ucsXdir & ucsYdir
copy the text to a new location and get it's database list
(setq elist (entget (entlast)))
Now how can i set the object ucs in elist?
maybe instead of using COPY command to set the origin text UCS
and create the copied text with (entmake) would it align with the current UCS?
....
I haven't tested this [I leave that to you], but if you're talking about things rotated only about the Z axis, and want a new Text entity to have its rotation match the current UCS, I would think that you wouldn't need to check its own UCS characteristics, but regardless of what its current rotation is, could just give it a rotation angle equal to the current UCS X direction. Either make it using (entmake) and including
(cons 50 (getvar 'ucsxdir))
in the list, or Copy one and modify the copy using something like
(entmod (subst (cons 50 (getvar 'ucsxdir)) (assoc 50 elist) elist))
or convert it to a VLA object and impose (getvar 'ucsxdir) as its Rotation property with (vlax-put... methods.
what i meant is i want to know what was the XY direction of the ucs at the time the texts were drawn and i now understand that there is no such thing - am i right?
Correct - this information is not stored with an entity; only the information pertaining to the properties & geometry of an entity are available in the entity DXF data, the editor configuration (UCS / Views etc.) are not recorded with the entity data.
by the way about (entmake) & (entmakex) what is the difference between them?
Put simply, entmake returns the supplied DXF data if successful, whereas entmakex returns the entity name of the created entity if successful; there are other subtle differences pertaining to how objects owners are assigned, but in my experience this is rarely a significant issue.
(cons 50 (getvar 'ucsxdir))
in the list, or Copy one and modify the copy using something like
(entmod (subst (cons 50 (getvar 'ucsxdir)) (assoc 50 elist) elist))
FYI, (getvar 'ucsxdir) will return a vector (not an angle), therefore:
(angle '(0.0 0.0) (getvar 'ucsxdir))
Should be used; or, to account for all UCS construction planes:
(angle '(0.0 0.0) (trans (getvar 'ucsxdir) 0 (trans '(0.0 0.0 1.0) 1 0 t) t))
Lee_Mac wrote:FYI, (getvar 'ucsxdir) will return a vector (not an angle), therefore:
(angle '(0.0 0.0) (getvar 'ucsxdir))Should be used....
Yes, of course [shooting from the hip without actually looking at the content of the System Variable...].