天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 6|回复: 0

翻译 ENGLISH 需要模仿UCS V命令

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
How to Transform geometry data between model and paper space using ObjectARX/.Net?

Issue


How do I convert geometry data from paper space to model space for a particular
viewport?


Solution :


One approach is to use the function acedTrans (see the documentation for its
usage). Another is to use the data directly from the AcDbViewport. The
following code converts data from paper space in the corresponding viewport to
model space. The opposite conversion can be done by inverting the matrix
calculated.

/*Code*/
//////////////////////////////////////////////////////////////////////////
// model space to paper space
static void ms2ps(AcDbViewport*pVp, AcGeMatrix3d &resultMat);
// visa versa
static void ps2ms(AcDbViewport*pVp, AcGeMatrix3d &resultMat);
//////////////////////////////////////////////////////////////////////////
// This is command 'ALIGN, by Fenton Webb [12/10/2004], DevTech, Autodesk
void asdkUTILSAlign()
{
// First select a viewport to calculate the transformation for
ads_name eName;
ads_point pt;
if( RTNORM != acedEntSel("\nPlease pick a viewport", eName, pt ))
  return;
// Get The Id
AcDbObjectId id;
acdbGetObjectId(id, eName);

// Open up the viewport
AcDbObjectPointer<AcDbViewport> pVp (id, AcDb::kForRead);
// if ok
if (pVp.openStatus() == Acad::eOk)
{
  // Open the ModelSpace Record
  AcDbBlockTableRecordPointer pMsRecord (ACDB_MODEL_SPACE, curDoc()->database(), AcDb::kForWrite);
  // if ok
  if (pMsRecord.openStatus() == Acad::eOk)
  {
   // Pick a line
   if( RTNORM != acedEntSel( "\nPlease select Paper space line\n", eName, pt ) )
    return;
   acdbGetObjectId( id, eName );

   // Get the projection matrix
   AcGeMatrix3d ms2PsMat;
   ps2ms(pVp.object(), ms2PsMat);
   // Open the line
   AcDbObjectPointer<AcDbLine> pPsLine (id, AcDb::kForRead);
   // if ok
   if (pPsLine.openStatus() == Acad::eOk)
   {
    AcDbEntity *pMsEntity = NULL;
    // Now get a transformed copy
    pPsLine->getTransformedCopy( ms2PsMat, pMsEntity);
    if(pMsEntity != NULL )
    {
     // create a smart pointer
     AcDbObjectPointer<AcDbEntity> pMsEntitySmartPtr;
     // acquire the newly created pointer - now we don't need to worry about closing
     pMsEntitySmartPtr.acquire(pMsEntity);
     // Change its color, so we can see the new entity!
     pMsEntitySmartPtr->setColorIndex(2);
     // now add it to model space
     pMsRecord->appendAcDbEntity(pMsEntitySmartPtr.object());
    }
   }
  }
}
}
//////////////////////////////////////////////////////////////////////////
void ms2ps( AcDbViewport*pVp, AcGeMatrix3d &resultMat)
{
// first get all the data
AcGeVector3d viewDirection = pVp->viewDirection();
AcGePoint2d centre2d = pVp->viewCenter();
AcGePoint3d viewCenter = AcGePoint3d( centre2d.x, centre2d.y, 0);

AcGePoint3d viewTarget = pVp->viewTarget ();
double twistAngle = -pVp->twistAngle();
AcGePoint3d centerPoint = pVp->centerPoint();
double viewHeight = pVp->viewHeight();
double height = pVp->height();
double width = pVp->width();
double scaling = viewHeight / height;
double lensLength = pVp->lensLength();

// prepare the transformation
AcGeVector3d xAxis, yAxis, zAxis;
zAxis = viewDirection.normal();
xAxis = AcGeVector3d::kZAxis.crossProduct( viewDirection );

if( !xAxis.isZeroLength() ) {
  xAxis.normalize();
  yAxis = zAxis.crossProduct( xAxis );
} else if( zAxis.z < 0 ) {
  xAxis = -AcGeVector3d::kXAxis;
  yAxis = AcGeVector3d::kYAxis;
  zAxis = -AcGeVector3d::kZAxis;
} else {
  xAxis = AcGeVector3d::kXAxis;
  yAxis = AcGeVector3d::kYAxis;
  zAxis = AcGeVector3d::kZAxis;
}

AcGeMatrix3d dcs2wcs; // display coordinate system (DCS) to world coordinate system (WCS)
AcGeMatrix3d ps2Dcs; // paperspace to DCS


// First initialise with a transformation to centerPoint
ps2Dcs = AcGeMatrix3d::translation( AcGePoint3d::kOrigin - centerPoint);

// then scale for the view
ps2Dcs = ps2Dcs * AcGeMatrix3d::scaling( scaling, centerPoint);

// then adjust to the viewCenter
dcs2wcs = AcGeMatrix3d::translation( viewCenter - AcGePoint3d::kOrigin);

// Then transform for the view direction
AcGeMatrix3d matCoords;
matCoords.setCoordSystem( AcGePoint3d::kOrigin, xAxis, yAxis, zAxis);

dcs2wcs = matCoords * dcs2wcs;

// Then adjust for the viewTarget
dcs2wcs = AcGeMatrix3d::translation( viewTarget - AcGePoint3d::kOrigin) * dcs2wcs;

// Then the twist angle
dcs2wcs = AcGeMatrix3d::rotation(twistAngle, zAxis, viewTarget ) *dcs2wcs;

AcGeMatrix3d perspMat;
if( pVp->isPerspectiveOn())
{
  // we do special perspective handling
  double viewSize = viewHeight;
  double aspectRatio = width / height;
  
  double adjustFactor = 1.0 / 42.0;
  double adjustedLensLength = viewSize * lensLength * sqrt ( 1.0 +
   aspectRatio * aspectRatio ) * adjustFactor;
  
  double eyeDistance = viewDirection.length();
  double lensDistance = eyeDistance - adjustedLensLength;
  
  
  double ed = eyeDistance;
  double ll = adjustedLensLength;
  double l = lensDistance;
  
  
  perspMat.entry[2][2] = (ll - l ) / ll;
  perspMat.entry[2][3] = l * ( ed - ll ) / ll;
  perspMat.entry[3][2] = -1.0 / ll;
  perspMat.entry[3][3] = ed / ll;  
}

resultMat = ps2Dcs.inverse() * perspMat * dcs2wcs.inverse();
}
//////////////////////////////////////////////////////////////////////////
void ps2ms ( AcDbViewport*pVp, AcGeMatrix3d &resultMat )
{
// Keep life simple, just invert the other way
AcGeMatrix3d mat;
ms2ps( pVp, mat );
resultMat = mat.inverse();
return;
}



Here is a C# version of this code:
static Matrix3d ms2ps(Viewport pVp)
{
    // first get all the data
    Vector3d viewDirection = pVp.ViewDirection;
    Point3d viewCenter = new Point3d(pVp.ViewCenter.X, pVp.ViewCenter.Y, 0);
    Point3d viewTarget = pVp.ViewTarget;
    Point3d centerPoint = pVp.CenterPoint;

    double twistAngle = -pVp.TwistAngle;
    double viewHeight = pVp.ViewHeight;
    double height = pVp.Height;
    double width = pVp.Width;
    double scaling = viewHeight / height;
    double lensLength = pVp.LensLength;

    // prepare the transformation
    Vector3d zAxis = viewDirection.GetNormal();
    Vector3d xAxis = Vector3d.ZAxis.CrossProduct(viewDirection);
    Vector3d yAxis;

    if (!xAxis.IsZeroLength())
    {
        xAxis = xAxis.GetNormal();
        yAxis = zAxis.CrossProduct(xAxis);
    }
    else if (zAxis.Z < 0)
    {
        xAxis = Vector3d.XAxis * -1;
        yAxis = Vector3d.YAxis;
        zAxis = Vector3d.ZAxis * -1;
    }
    else
    {
        xAxis = Vector3d.XAxis;
        yAxis = Vector3d.YAxis;
        zAxis = Vector3d.ZAxis;
    }

    Matrix3d dcs2wcs; // display coordinate system (DCS) to world coordinate system (WCS)
    Matrix3d ps2Dcs;  // paperspace to DCS


    // First initialise with a transformation to centerPoint
    ps2Dcs = Matrix3d.Displacement(Point3d.Origin - centerPoint);

    // then scale for the view
    ps2Dcs = ps2Dcs * Matrix3d.Scaling(scaling, centerPoint);

    // then adjust to the viewCenter
    dcs2wcs = Matrix3d.Displacement(viewCenter - Point3d.Origin);

    // Then transform for the view direction
    Matrix3d matCoords = Matrix3d.AlignCoordinateSystem(Point3d.Origin,
        Vector3d.XAxis,
        Vector3d.YAxis,
        Vector3d.ZAxis,
        Point3d.Origin,
        xAxis,
        yAxis,
        zAxis);

    dcs2wcs = matCoords * dcs2wcs;

    // Then adjust for the viewTarget
    dcs2wcs = Matrix3d.Displacement(viewTarget - Point3d.Origin) * dcs2wcs;

    // Then the twist angle
    dcs2wcs = Matrix3d.Rotation(twistAngle, zAxis, viewTarget) * dcs2wcs;


    Matrix3d perspMat = Matrix3d.Identity;

    if (pVp.PerspectiveOn)
    {
        // we do special perspective handling
        double viewSize = viewHeight;
        double aspectRatio = width / height;

        double adjustFactor = 1.0 / 42.0;
        double adjustedLensLength = viewSize * lensLength * Math.Sqrt(1.0 + aspectRatio * aspectRatio) * adjustFactor;

        double eyeDistance = viewDirection.Length;
        double lensDistance = eyeDistance - adjustedLensLength;

        double ed = eyeDistance;
        double ll = adjustedLensLength;
        double l = lensDistance;

        double[] data = new double[] {1,0,0,0,
                                      0,1,0,0,
                                      0,0, (ll - l ) / ll, l * ( ed - ll ) / ll,
                                      0,0, -1.0/ll, ed/ll};

        perspMat = new Matrix3d(data);
    }

    Matrix3d resultMat = ps2Dcs.Inverse() * perspMat * dcs2wcs.Inverse();

    return resultMat;
}

[CommandMethod("ConvertModel2Paper")]
static public void ConvertModel2Paper()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    Editor ed = doc.Editor;

    PromptEntityOptions peo = new PromptEntityOptions("\nSelect a viewport: ");
    peo.SetRejectMessage("\nMust be a viewport...");
    peo.AddAllowedClass(typeof(Viewport), true);

    PromptEntityResult per = ed.GetEntity(peo);

    if (per.Status != PromptStatus.OK)
        return;

    using (Transaction Tx = db.TransactionManager.StartTransaction())
    {
        Viewport vp = Tx.GetObject(per.ObjectId, OpenMode.ForRead) as Viewport;

        Matrix3d Transfo = ms2ps(vp);

        BlockTable bT = Tx.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;

        BlockTableRecord btrModel = Tx.GetObject(bT[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
        BlockTableRecord btrPaper = Tx.GetObject(bT[BlockTableRecord.PaperSpace], OpenMode.ForWrite) as BlockTableRecord;

        foreach (ObjectId id in btrModel)
        {
            Entity entity = Tx.GetObject(id, OpenMode.ForRead) as Entity;
            
            Entity paperEntity = entity.Clone() as Entity;

            paperEntity.TransformBy(Transfo);
            paperEntity.ColorIndex = 1;

            btrPaper.AppendEntity(paperEntity);

            Tx.AddNewlyCreatedDBObject(paperEntity, true);
        }
        
        Tx.Commit();
    }
}

static Matrix3d ps2ms(Viewport pVp)
{
    Matrix3d mat = ms2ps(pVp);
    return mat.Inverse();
}

[CommandMethod("ConvertPaper2Model")]
static public void ConvertPaper2Model()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    Editor ed = doc.Editor;

    PromptEntityOptions peo = new PromptEntityOptions("\nSelect a viewport: ");
    peo.SetRejectMessage("\nMust be a viewport...");
    peo.AddAllowedClass(typeof(Viewport), true);

    PromptEntityResult per = ed.GetEntity(peo);

    if (per.Status != PromptStatus.OK)
        return;

    using (Transaction Tx = db.TransactionManager.StartTransaction())
    {
        Viewport vp = Tx.GetObject(per.ObjectId, OpenMode.ForWrite) as Viewport;

        Matrix3d ps2msTransfo = ps2ms(vp);

        BlockTable b = Tx.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
        BlockTableRecord btr = Tx.GetObject(b[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;


        //Boundary
        Point3d p1 = new Point3d(vp.CenterPoint.X - vp.Width * 0.5, vp.CenterPoint.Y - vp.Height * 0.5, 0);
        Point3d p2 = new Point3d(vp.CenterPoint.X - vp.Width * 0.5, vp.CenterPoint.Y + vp.Height * 0.5, 0);
        Point3d p3 = new Point3d(vp.CenterPoint.X + vp.Width * 0.5, vp.CenterPoint.Y + vp.Height * 0.5, 0);
        Point3d p4 = new Point3d(vp.CenterPoint.X + vp.Width * 0.5, vp.CenterPoint.Y - vp.Height * 0.5, 0);

        Line l1 = new Line(p1, p2);
        Line l2 = new Line(p2, p3);
        Line l3 = new Line(p3, p4);
        Line l4 = new Line(p4, p1);

        l1.TransformBy(ps2msTransfo);
        l2.TransformBy(ps2msTransfo);
        l3.TransformBy(ps2msTransfo);
        l4.TransformBy(ps2msTransfo);

        btr.AppendEntity(l1);
        btr.AppendEntity(l2);
        btr.AppendEntity(l3);
        btr.AppendEntity(l4);

        Tx.AddNewlyCreatedDBObject(l1, true);
        Tx.AddNewlyCreatedDBObject(l2, true);
        Tx.AddNewlyCreatedDBObject(l3, true);
        Tx.AddNewlyCreatedDBObject(l4, true);


        //Paper Space Entity
        peo = new PromptEntityOptions("\nSelect a paper space line: ");
        peo.SetRejectMessage("\nMust be a line...");
        peo.AddAllowedClass(typeof(Line), true);

        per = ed.GetEntity(peo);

        if (per.Status != PromptStatus.OK) return;

        Line line = Tx.GetObject(per.ObjectId, OpenMode.ForRead) as Line;

        Entity clonedLine = line.GetTransformedCopy(ps2msTransfo);

        //Set color to red so we can reconize it easily
        clonedLine.ColorIndex = 1;

        btr.AppendEntity(clonedLine);
        Tx.AddNewlyCreatedDBObject(clonedLine, true);

        Tx.Commit();
    }
}


/*Code*/

 

 

 

 

翻译  ENGLISH 需要模仿UCS V命令

该用户从未签到

主题

0

回帖

0

积分

管理员

积分
0
发表于 2024-7-28 09:28:43 | 显示全部楼层
  法拉利膜材作为一种高性能的建筑材料,在建筑、汽车及广告等多个领域有着广泛的应用。以下是对法拉利膜材型号、特点及优点的详细分析:
[img]http://www.mjgou.com/data/attachment/forum/202403/13/223041uiqmeujen4jjj6zv.jpg[/img]
[b]一、法拉利膜材型号[/b]
法拉利膜材有多种型号,包括但不限于以下几种:1302 S2 Flexlight Advanced:这是一种高性能IV型柔性复合膜材,以其卓越的透光性、耐久性和易维护性而受到青睐。942、1202 S2、1002 S2、902 S2、1212 S2、912 S2:这些型号同样属于法拉利膜材系列,各自具有不同的特性和适用范围,但具体特点需根据具体型号进一步分析。需要注意的是,法拉利膜材的型号可能随着产品更新换代而有所变化,具体型号及其特性请参考最新产品资料。
[img=860,1255]http://www.mjgou.com/data/attachment/forum/202403/13/223254bbblwlbvbvsbwlsl.jpg[/img]
[b]二、法拉利膜材特点[/b]
法拉利膜材的特点主要体现在以下几个方面:
1、高强度与耐用性:法拉利膜材采用高强度材料制成,具有良好的抗拉强度和撕裂强度,能够承受较大的外力作用而不易破损。耐用性强,能够在恶劣气候条件下保持稳定的性能,延长使用寿命。
2、透光性与美观性:部分型号如1302 S2 Flexlight Advanced具有高透光性,能够在保持室内光线充足的同时,提供清晰的视野。膜材表面平整光滑,色彩丰富多样,能够满足不同建筑和装饰需求,提升整体美观性。
3、轻质与灵活性:法拉利膜材重量较轻,便于运输和安装,能够降低施工成本和时间。膜材具有一定的柔韧性,能够适应各种复杂形状和结构的设计要求。
4、环保与可回收性:法拉利膜材符合环保要求,部分材料可回收利用,减少了对环境的影响。
[img]http://www.mjgou.com/data/attachment/forum/202403/13/223128owhn0099rrds5h5y.jpg[/img]
[b]三、法拉利膜材优点[/b]
法拉利膜材的优点主要体现在以下几个方面:
1、提升建筑性能:高强度与耐用性使得法拉利膜材能够提升建筑的稳定性和安全性,延长使用寿命。透光性与美观性使得建筑内部光线充足、视野开阔,同时提升整体美观度。
2、降低施工成本:轻质特性使得运输和安装成本降低,施工效率提高。膜材的柔韧性使得施工更加灵活多变,能够适应各种复杂地形和结构要求。
3、节能环保:部分材料可回收利用,符合环保要求,减少了对环境的影响。良好的透光性能够减少室内照明需求,降低能耗。
4、广泛应用领域:
法拉利膜材不仅适用于建筑领域(如体育设施、商业设施、文化设施、交通设施等),还广泛应用于汽车及广告领域(如高档车辆贴膜保护和装饰、广告招贴等),展现出其多功能的特性。

综上所述,法拉利膜材以其高强度、耐用性、透光性、美观性、轻质灵活性以及环保可回收性等优点,在建筑、汽车及广告等多个领域发挥着重要作用。具体型号的选择应根据实际需求和应用场景进行综合考虑。
[url=http://www.mjgou.com/forum-17-1.html][size=95110][color=Red]法拉利膜材中国代理商 - 膜结构网[/color][/size][/url]
翻译  ENGLISH 需要模仿UCS V命令

该用户从未签到

主题

0

回帖

30

积分

新手上路

积分
30
发表于 2024-8-6 10:42:43 | 显示全部楼层
杜肯膜材,特别是德国杜肯(duraskin)膜材,是德国Verseidag-Indutex GmbH公司的核心产品,该公司位于德国的西北部城市Krefeld。以下是对杜肯膜材的详细分析:
[b]一、公司背景与实力[/b]
公司实力:杜肯(duraskin)膜材年销售金额达到7000万欧元,是目前世界上唯一一家既生产PVC类膜材又生产PTFE类膜材的公司。
技术领先:Verseidag-Indutex GmbH的涂层技术及新型功能性膜材的技术开发在世界上是数一数二的,产品品质的稳定性和技术的先进性令世界同行羡慕不已。
[b]二、产品种类与特点[/b]
PVC膜材
特点:杜肯PVC膜材表面涂层采用“不可焊接PVDF”,大大提高了膜材的自洁性和使用寿命。其最大宽幅可达到5米,是世界上最宽的PVC膜材之一。
应用:广泛用于建筑膜结构、车棚、遮阳篷等领域。
PTFE膜材
特点:PTFE膜材具有优异的自洁性、耐候性、耐腐蚀性和超长使用寿命,被称为“永久性膜材”。其最大宽幅达到4.7米,也是世界上最宽的PTFE膜材之一。
应用:特别适用于大型公共建筑、体育场馆、机场航站楼等对膜材性能要求极高的场所。
其他功能性膜材
杜肯还生产高透光膜材、吸音内膜、Low-e节能膜材、彩色膜材、纳米二氧化钛TiO2膜材等多种功能性膜材,以满足不同客户的需求。
[b]三、产品优势[/b]
品质稳定:杜肯膜材品质非常稳定,在世界各地都有众多的成功工程案例。
保险承保:杜肯膜材能获得德国多家保险公司的10年100%的产品责任保险,为客户提供额外的保障。
技术领先:杜肯膜材在涂层技术和新型功能性膜材的技术开发方面处于世界领先地位。
[b]四、市场与应用[/b]
全球市场:杜肯膜材在全球范围内拥有广泛的应用市场,特别是在欧洲、北美等地区的大型公共建筑和体育场馆项目中占据重要地位。
成功案例:杜肯膜材在斯图加特体育场、德国Halle网球中心、奥地利机场停车场、土耳其安卡拉体育场等众多知名项目中得到应用,并获得了良好的口碑。
[b]五、总结[/b]
杜肯膜材以其卓越的品质、先进的技术和广泛的应用领域在全球市场上赢得了良好的声誉。作为世界上唯一一家既生产PVC类膜材又生产PTFE类膜材的公司,杜肯膜材在膜材行业中具有举足轻重的地位。未来,随着科技的不断进步和市场的不断发展,杜肯膜材将继续保持其领先地位,为客户提供更加优质的产品和服务。

 

 

 

 

翻译  ENGLISH 需要模仿UCS V命令
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 10:30 , Processed in 0.163682 second(s), 28 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表